-rw-r--r-- | noncore/apps/opie-sheet/cellformat.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/cellformat.h | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/finddlg.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/finddlg.h | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/main.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.h | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/numberdlg.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/numberdlg.h | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sheet.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sheet.h | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sortdlg.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/sortdlg.h | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/textdlg.cpp | 14 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/textdlg.h | 14 |
15 files changed, 210 insertions, 0 deletions
diff --git a/noncore/apps/opie-sheet/cellformat.cpp b/noncore/apps/opie-sheet/cellformat.cpp index 6a2ff72..597502c 100644 --- a/noncore/apps/opie-sheet/cellformat.cpp +++ b/noncore/apps/opie-sheet/cellformat.cpp @@ -1,96 +1,110 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #include "cellformat.h" #include <qlistbox.h> #include <qlabel.h> #define COMBO_WIDTHS 155 #define COMBO_HEIGHTS 21 #define COLOR_COUNT 17 #define STYLE_COUNT 14 #define HALIGN_COUNT 3 #define VALIGN_COUNT 3 QColor 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}; Qt::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}; QString namesHAlign[HALIGN_COUNT]={"Left", "Right", "Center"}; QString namesVAlign[VALIGN_COUNT]={"Top", "Bottom", "Center"}; Qt::AlignmentFlags flagsHAlign[HALIGN_COUNT]={Qt::AlignLeft, Qt::AlignRight, Qt::AlignHCenter}; Qt::AlignmentFlags flagsVAlign[VALIGN_COUNT]={Qt::AlignTop, Qt::AlignBottom, Qt::AlignVCenter}; CellFormat::CellFormat(QWidget *parent=0) :QDialog(parent, 0, TRUE) { // Main widget tabs=new QTabWidget(this); widgetBorders=new QWidget(tabs); widgetBackground=new QWidget(tabs); widgetFont=new QWidget(tabs); widgetAlignment=new QWidget(tabs); tabs->addTab(widgetBorders, tr("&Borders")); tabs->addTab(widgetBackground, tr("Back&ground")); tabs->addTab(widgetFont, tr("&Font")); tabs->addTab(widgetAlignment, tr("&Alignment")); fontDB.loadRenderers(); changedFont=changedAlign=changedBrush=FALSE; // Borders tab borderEditor=new BorderEditor(widgetBorders); borderEditor->setGeometry(10, 10, 215, 145); connect(borderEditor, SIGNAL(clicked(BorderEditor::BorderArea)), this, SLOT(borderClicked(BorderEditor::BorderArea))); comboBordersWidth=createCombo(COMBO_WIDTH, widgetBorders, tr("&Width:"), 165); comboBordersColor=createCombo(COMBO_COLOR, widgetBorders, tr("&Color:"), 165+(COMBO_HEIGHTS+10)); buttonBordersDefaults=new QPushButton(tr("&Default Borders"), widgetBorders); buttonBordersDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); connect(buttonBordersDefaults, SIGNAL(clicked()), this, SLOT(slotBordersDefaults())); // Background tab frameBackground=new QFrame(widgetBackground); frameBackground->setGeometry(10, 10, 215, 145); frameBackground->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); comboBackgroundStyle=createCombo(COMBO_STYLE, widgetBackground, tr("&Style:"), 165); connect(comboBackgroundStyle, SIGNAL(activated(int)), this, SLOT(backgroundClicked(int))); comboBackgroundColor=createCombo(COMBO_COLOR, widgetBackground, tr("&Color:"), 165+(COMBO_HEIGHTS+10)); connect(comboBackgroundColor, SIGNAL(activated(int)), this, SLOT(backgroundClicked(int))); buttonBackgroundDefaults=new QPushButton(tr("&Default Background"), widgetBackground); buttonBackgroundDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); connect(buttonBackgroundDefaults, SIGNAL(clicked()), this, SLOT(slotBackgroundDefaults())); // Font tab frameFont=new QFrame(widgetFont); frameFont->setGeometry(10, 10, 215, 125); frameFont->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); comboFontFamily=createCombo(COMBO_FONT, widgetFont, tr("&Font:"), 145); connect(comboFontFamily, SIGNAL(activated(int)), this, SLOT(fontClicked(int))); comboFontSize=createCombo(COMBO_SIZE, widgetFont, tr("&Size:"), 145+(COMBO_HEIGHTS+10)); connect(comboFontSize, SIGNAL(activated(int)), this, SLOT(fontClicked(int))); comboFontColor=createCombo(COMBO_COLOR, widgetFont, tr("&Color:"), 145+2*(COMBO_HEIGHTS+10)); connect(comboFontColor, SIGNAL(activated(int)), this, SLOT(fontClicked(int))); checkFontBold=new QCheckBox(tr("&Bold"), widgetFont); checkFontBold->setGeometry(10, 145+3*(COMBO_HEIGHTS+10), 40, COMBO_HEIGHTS); connect(checkFontBold, SIGNAL(toggled(bool)), this, SLOT(fontClicked(bool))); checkFontItalic=new QCheckBox(tr("&Italic"), widgetFont); checkFontItalic->setGeometry(60, 145+3*(COMBO_HEIGHTS+10), 40, COMBO_HEIGHTS); connect(checkFontItalic, SIGNAL(toggled(bool)), this, SLOT(fontClicked(bool))); buttonFontDefaults=new QPushButton(tr("&Default Font"), widgetFont); buttonFontDefaults->setGeometry(115, 145+3*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); connect(buttonFontDefaults, SIGNAL(clicked()), this, SLOT(slotFontDefaults())); // Alignment tab frameAlignment=new QFrame(widgetAlignment); frameAlignment->setGeometry(10, 10, 215, 145); frameAlignment->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); comboAlignmentVertical=createCombo(COMBO_VALIGN, widgetAlignment, tr("&Vertical:"), 165); connect(comboAlignmentVertical, SIGNAL(activated(int)), this, SLOT(alignClicked(int))); comboAlignmentHorizontal=createCombo(COMBO_HALIGN, widgetAlignment, tr("&Horizontal:"), 165+(COMBO_HEIGHTS+10)); connect(comboAlignmentHorizontal, SIGNAL(activated(int)), this, SLOT(alignClicked(int))); diff --git a/noncore/apps/opie-sheet/cellformat.h b/noncore/apps/opie-sheet/cellformat.h index b552153..b569b7f 100644 --- a/noncore/apps/opie-sheet/cellformat.h +++ b/noncore/apps/opie-sheet/cellformat.h @@ -1,96 +1,110 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #ifndef CELLFORMAT_H #define CELLFORMAT_H #include <qpe/fontdatabase.h> #include <qdialog.h> #include <qtabwidget.h> #include <qlayout.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qpushbutton.h> #include "sheet.h" class BorderEditor: public QFrame { Q_OBJECT // QT objects QPen penTop, penBottom, penLeft, penRight, penHorz, penVert; // Private functions void drawContents(QPainter *p); // Reimplemented QFrame functions void mouseReleaseEvent(QMouseEvent *e); public: // Definitions enum BorderArea {None, Top, Bottom, Left, Right, Horz, Vert}; BorderEditor(QWidget *parent=0); ~BorderEditor(); void setPen(const QPen &pen, BorderArea area); QPen getPen(BorderArea area); QPen getDefaultPen() { return QPen(Qt::black, 1, Qt::DotLine); } signals: void clicked(BorderEditor::BorderArea); }; class CellFormat: public QDialog { Q_OBJECT enum comboType {COMBO_OTHER, COMBO_WIDTH, COMBO_FONT, COMBO_SIZE, COMBO_STYLE, COMBO_COLOR, COMBO_VALIGN, COMBO_HALIGN}; // QT objects QBoxLayout *box; QTabWidget *tabs; QWidget *widgetBorders, *widgetBackground, *widgetFont, *widgetAlignment; QComboBox *comboBordersWidth, *comboBordersColor, *comboBackgroundColor, *comboBackgroundStyle, *comboFontColor, *comboFontSize, *comboFontFamily, *comboAlignmentVertical, *comboAlignmentHorizontal; QCheckBox *checkFontBold, *checkFontItalic, *checkAlignmentWrap; QPushButton *buttonBordersDefaults, *buttonBackgroundDefaults, *buttonFontDefaults, *buttonAlignmentDefaults; QFrame *frameBackground, *frameFont, *frameAlignment; QBrush brushBackground; QFont fontFont; QColor fontColor; Qt::AlignmentFlags textAlignment; FontDatabase fontDB; // Other objects & variables Sheet *sheet; BorderEditor *borderEditor; bool changedFont, changedAlign, changedBrush; // Private functions void createWidthCombo(QComboBox *combo); void createFontCombo(QComboBox *combo); void createHAlignCombo(QComboBox *combo); void createVAlignCombo(QComboBox *combo); void createStyleCombo(QComboBox *combo); void createSizeCombo(QComboBox *combo); void createColorCombo(QComboBox *combo); QComboBox *createCombo(comboType type, QWidget *parent, const QString &caption, int y); int findHAlignIndex(Qt::AlignmentFlags flag); int findVAlignIndex(Qt::AlignmentFlags flag); int findComboItemIndex(QComboBox *combo, const QString &item); int findColorIndex(const QColor &color); int findBrushStyleIndex(Qt::BrushStyle style); private slots: void borderClicked(BorderEditor::BorderArea area); void backgroundClicked(int index); void fontClicked(bool on); void fontClicked(int index); void alignClicked(bool on); void alignClicked(int index); void slotBordersDefaults(); void slotBackgroundDefaults(); void slotFontDefaults(); void slotAlignmentDefaults(); public: CellFormat(QWidget *parent=0); diff --git a/noncore/apps/opie-sheet/finddlg.cpp b/noncore/apps/opie-sheet/finddlg.cpp index cfe2f82..d1237ca 100644 --- a/noncore/apps/opie-sheet/finddlg.cpp +++ b/noncore/apps/opie-sheet/finddlg.cpp @@ -1,70 +1,84 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #include <qlabel.h> #include <qradiobutton.h> #include "finddlg.h" FindDialog::FindDialog(QWidget *parent=0) :QDialog(parent, 0, TRUE) { // Main widget tabs=new QTabWidget(this); widgetFind=new QWidget(tabs); widgetOptions=new QWidget(tabs); tabs->addTab(widgetFind, tr("&Find && Replace")); tabs->addTab(widgetOptions, tr("&Options")); // Find tab QLabel *label=new QLabel(tr("&Search for:"), widgetFind); label->setGeometry(10, 10, 215, 20); editFind=new QLineEdit(widgetFind); editFind->setGeometry(10, 40, 215, 20); label->setBuddy(editFind); label=new QLabel(tr("&Replace with:"), widgetFind); label->setGeometry(10, 80, 215, 20); editReplace=new QLineEdit(widgetFind); editReplace->setGeometry(10, 110, 215, 20); editReplace->setEnabled(FALSE); label->setBuddy(editReplace); groupType=new QVButtonGroup(tr("&Type"), widgetFind); groupType->setGeometry(10, 150, 215, 90); QRadioButton *radio=new QRadioButton(tr("&Find"), groupType); radio=new QRadioButton(tr("&Replace"), groupType); radio=new QRadioButton(tr("Replace &all"), groupType); groupType->setButton(0); connect(groupType, SIGNAL(clicked(int)), this, SLOT(typeChanged(int))); // Options tab checkCase=new QCheckBox(tr("Match &case"), widgetOptions); checkCase->setGeometry(10, 10, 215, 20); checkSelection=new QCheckBox(tr("Current &selection only"), widgetOptions); checkSelection->setGeometry(10, 40, 215, 20); checkEntire=new QCheckBox(tr("&Entire cell"), widgetOptions); checkEntire->setGeometry(10, 70, 215, 20); // Main widget box=new QVBoxLayout(this); box->addWidget(tabs); setCaption(tr("Find & Replace")); } FindDialog::~FindDialog() { } void FindDialog::typeChanged(int id) { editReplace->setEnabled(id>0); } int FindDialog::exec(Sheet *s) { if (QDialog::exec()==QDialog::Accepted) { int id=groupType->id(groupType->selected()); s->dataFindReplace(editFind->text(), editReplace->text(), checkCase->isChecked(), !checkSelection->isChecked(), checkEntire->isChecked(), id>0, id>1); return QDialog::Accepted; } return QDialog::Rejected; } diff --git a/noncore/apps/opie-sheet/finddlg.h b/noncore/apps/opie-sheet/finddlg.h index 02c9cdd..1af2da5 100644 --- a/noncore/apps/opie-sheet/finddlg.h +++ b/noncore/apps/opie-sheet/finddlg.h @@ -1,35 +1,49 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #ifndef FINDDLG_H #define FINDDLG_H #include <qdialog.h> #include <qtabwidget.h> #include <qlayout.h> #include <qlineedit.h> #include <qcheckbox.h> #include <qpushbutton.h> #include <qvbuttongroup.h> #include "sheet.h" class FindDialog: public QDialog { Q_OBJECT // QT objects QBoxLayout *box; QTabWidget *tabs; QWidget *widgetFind, *widgetOptions; QCheckBox *checkCase, *checkSelection, *checkEntire; QLineEdit *editFind, *editReplace; QVButtonGroup *groupType; private slots: void typeChanged(int id); public: FindDialog(QWidget *parent=0); ~FindDialog(); int exec(Sheet *s); }; #endif diff --git a/noncore/apps/opie-sheet/main.cpp b/noncore/apps/opie-sheet/main.cpp index 236a579..e42b4a5 100644 --- a/noncore/apps/opie-sheet/main.cpp +++ b/noncore/apps/opie-sheet/main.cpp @@ -1,14 +1,28 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #include <qpe/qpeapplication.h> #include "mainwindow.h" int main(int argc, char **argv) { QPEApplication application(argc, argv); MainWindow windowMain; windowMain.setHelpFile(application.qpeDir()+"/help/html/"+QString(argv[0])+".html"); application.showMainDocumentWidget(&windowMain); return application.exec(); } diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index a7441b1..9d69b8a 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp @@ -1,96 +1,110 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #include "mainwindow.h" #include <qpe/filemanager.h> #include <qpe/qcopenvelope_qws.h> #include <qmessagebox.h> #include <qfile.h> #include <qradiobutton.h> #include "cellformat.h" #include "numberdlg.h" #include "textdlg.h" #include "sortdlg.h" #include "finddlg.h" #include "file-new.xpm" #include "file-open.xpm" #include "file-save.xpm" #include "edit-cancel.xpm" #include "edit-accept.xpm" #include "help-general.xpm" #include "func-plus.xpm" #include "func-minus.xpm" #include "func-cross.xpm" #include "func-divide.xpm" #include "func-paran-open.xpm" #include "func-paran-close.xpm" #include "func-comma.xpm" #include "func-func.xpm" #include "func-equal.xpm" #include "cell-select.xpm" #define DEFAULT_NUM_ROWS 199 #define DEFAULT_NUM_COLS (26*3) #define DEFAULT_NUM_SHEETS 3 MainWindow::MainWindow() :QMainWindow() { // initialize variables documentModified=FALSE; // construct objects fileSelector=new FileSelector("application/sheet-qt", this, QString::null); connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); listSheets.setAutoDelete(TRUE); initActions(); initMenu(); initEditToolbar(); initFunctionsToolbar(); initStandardToolbar(); initSheet(); // set window title setCaption(tr("Opie Sheet")); // create sheets selectorFileNew(currentDoc); } MainWindow::~MainWindow() { } void MainWindow::documentSave(DocLnk &lnkDoc) { FileManager fm; QByteArray streamBuffer; QDataStream stream(streamBuffer, IO_WriteOnly); typeSheet *currentSheet=findSheet(sheet->getName()); if (!currentSheet) { QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); return; } sheet->copySheetData(¤tSheet->data); stream.writeRawBytes("SQT100", 6); stream << (Q_UINT32)listSheets.count(); for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) { stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; } lnkDoc.setType("application/sheet-qt"); if (!fm.saveFile(lnkDoc, streamBuffer)) { QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); return; } documentModified=FALSE; } diff --git a/noncore/apps/opie-sheet/mainwindow.h b/noncore/apps/opie-sheet/mainwindow.h index ac90504..554e6f6 100644 --- a/noncore/apps/opie-sheet/mainwindow.h +++ b/noncore/apps/opie-sheet/mainwindow.h @@ -1,96 +1,110 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qpe/applnk.h> #include <qpe/fileselector.h> #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qmainwindow.h> #include <qaction.h> #include <qlineedit.h> #include <qbutton.h> #include <qcombobox.h> #include <qtoolbutton.h> #include "sheet.h" typedef struct typeSheet { QString name; QList<typeCellData> data; }; class MainWindow: public QMainWindow { Q_OBJECT // QPE objects DocLnk currentDoc; QPEMenuBar *menu; QPEToolBar *toolbarFunctions, *toolbarEdit, *toolbarStandard; FileSelector *fileSelector; // QT objects QPopupMenu *menuFile, *menuEdit, *menuInsert, *menuFormat, *menuData, *menuHelp, *submenuFunc, *submenuFuncStd, *submenuFuncMath, *submenuFuncStat, *submenuRow, *submenuCol, *submenuSheet; QAction *fileNew, *fileOpen, *fileSave, *fileSaveAs, *fileQuit, *helpAbout, *editAccept, *editCancel, *formatCells, *funcPlus, *funcMinus, *funcCross, *funcDivide, *funcParanOpen, *funcParanClose, *funcComma, *funcEqual, *editCut, *editCopy, *editPaste, *editPasteContents, *editClear, *insertCols, *insertRows, *insertSheets, *insertCells, *rowHeight, *rowShow, *rowHide, *rowAdjust, *colWidth, *colShow, *colHide, *colAdjust, *sheetRename, *sheetRemove, *dataSort, *dataFindReplace, *editCellSelect, *helpGeneral; QLineEdit *editData; QButton *buttonUp, *buttonDown, *buttonLeft, *buttonRight; QComboBox *comboSheets; QToolButton *toolFunction; QList<typeSheet> listSheets; QString helpFile; // Other objects Sheet *sheet; // Variables bool documentModified; // Private functions void initMenu(); void initActions(); void initFunctionsToolbar(); void initEditToolbar(); void initStandardToolbar(); void initSheet(); void addToData(const QString &data); int saveCurrentFile(bool ask=TRUE); void documentOpen(const DocLnk &lnkDoc); void copyDocLnk(const DocLnk &source, DocLnk &target); void documentSave(DocLnk &lnkDoc); void closeEvent(QCloseEvent *e); void addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w); typeSheet *createNewSheet(); typeSheet *findSheet(const QString &name); private slots: void slotFileNew(); void slotFileOpen(); void slotFileSave(); void slotFileSaveAs(); void slotHelpAbout(); void slotHelpGeneral(); void slotEditAccept(); void slotEditCancel(); void slotEditPaste(); void slotEditPasteContents(); void slotFormatCells(); void slotInsertCells(); void slotInsertRows(); void slotInsertCols(); void slotInsertSheets(); void slotDataSort(); void slotDataFindReplace(); void slotRowHeight(); void slotRowAdjust(); void slotRowShow(); void slotRowHide(); void slotColumnWidth(); void slotColumnAdjust(); void slotColumnShow(); diff --git a/noncore/apps/opie-sheet/numberdlg.cpp b/noncore/apps/opie-sheet/numberdlg.cpp index de84378..e8de639 100644 --- a/noncore/apps/opie-sheet/numberdlg.cpp +++ b/noncore/apps/opie-sheet/numberdlg.cpp @@ -1,35 +1,49 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #include "numberdlg.h" NumberDialog::NumberDialog(QWidget *parent=0) :QDialog(parent, 0, TRUE) { edit=new QSpinBox(this); edit->setGeometry(120, 10, 70, 25); label=new QLabel(this); label->setGeometry(10, 10, 100, 25); label->setBuddy(edit); resize(200, 45); } NumberDialog::~NumberDialog() { } int NumberDialog::exec(const QString &caption, const QString &text, int value=1, int min=1, int max=99, int step=1) { setCaption(caption); label->setText(text); edit->setValue(value); edit->setMinValue(min); edit->setMaxValue(max); edit->setLineStep(step); return QDialog::exec(); } int NumberDialog::getValue() { return edit->value(); } diff --git a/noncore/apps/opie-sheet/numberdlg.h b/noncore/apps/opie-sheet/numberdlg.h index 46af1d0..81e3326 100644 --- a/noncore/apps/opie-sheet/numberdlg.h +++ b/noncore/apps/opie-sheet/numberdlg.h @@ -1,24 +1,38 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #ifndef NUMBERDLG_H #define NUMBERDLG_H #include <qdialog.h> #include <qlabel.h> #include <qspinbox.h> class NumberDialog: public QDialog { Q_OBJECT // QT objects QLabel *label; QSpinBox *edit; public: NumberDialog(QWidget *parent=0); ~NumberDialog(); int exec(const QString &caption, const QString &text, int value=1, int min=1, int max=99, int step=1); int getValue(); }; #endif diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp index 9526937..1d7ec6f 100644 --- a/noncore/apps/opie-sheet/sheet.cpp +++ b/noncore/apps/opie-sheet/sheet.cpp @@ -1,96 +1,110 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #include "sheet.h" #include <qmainwindow.h> #include <qmessagebox.h> #include <math.h> #define DEFAULT_COL_WIDTH 50 Sheet::Sheet(int numRows, int numCols, QWidget *parent) :QTable(numRows, numCols, parent) { defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); defaultCellData.data=""; defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); defaultCellData.fontColor=Qt::black; defaultCellData.font=font(); defaultCellData.borders=defaultBorders; selectionNo=-1; setSelectionMode(QTable::Single); sheetData.setAutoDelete(TRUE); clipboardData.setAutoDelete(TRUE); for (int i=0; i<numCols; ++i) horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); connect(this, SIGNAL(currentChanged(int, int)), this, SLOT(slotCellSelected(int, int))); connect(this, SIGNAL(valueChanged(int, int)), this, SLOT(slotCellChanged(int, int))); } Sheet::~Sheet() { } typeCellData *Sheet::findCellData(int row, int col) { typeCellData *tempCellData; for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) if (tempCellData->row==row && tempCellData->col==col) return tempCellData; return NULL; } void Sheet::slotCellSelected(int row, int col) { typeCellData *cellData=findCellData(row, col); if (cellData) emit currentDataChanged(cellData->data); else emit currentDataChanged(""); } typeCellData *Sheet::createCellData(int row, int col) { if (row<0 || col<0) return NULL; typeCellData *cellData=new typeCellData; cellData->row=row; cellData->col=col; cellData->data=defaultCellData.data; cellData->borders=defaultCellData.borders; cellData->alignment=defaultCellData.alignment; cellData->font=defaultCellData.font; cellData->fontColor=defaultCellData.fontColor; cellData->background=defaultCellData.background; sheetData.append(cellData); return cellData; } void Sheet::slotCellChanged(int row, int col) { typeCellData *cellData=findCellData(row, col); if (!cellData) cellData=createCellData(row, col); if (cellData) cellData->data=text(row, col); for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) setText(cellData->row, cellData->col, dataParser(cellData->data)); emit sheetModified(); } void Sheet::swapCells(int row1, int col1, int row2, int col2) { typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); if (!cellData1) cellData1=createCellData(row1, col1); if (!cellData2) cellData2=createCellData(row2, col2); if (cellData1 && cellData2) { QString tempData(cellData1->data); cellData1->data=cellData2->data; cellData2->data=tempData; setText(cellData1->row, cellData1->col, dataParser(cellData1->data)); setText(cellData2->row, cellData2->col, dataParser(cellData2->data)); emit sheetModified(); } } QString Sheet::getParameter(const QString ¶meters, int paramNo, bool giveError=FALSE, const QString funcName="") diff --git a/noncore/apps/opie-sheet/sheet.h b/noncore/apps/opie-sheet/sheet.h index 02899a0..f78a684 100644 --- a/noncore/apps/opie-sheet/sheet.h +++ b/noncore/apps/opie-sheet/sheet.h @@ -1,96 +1,110 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #ifndef SHEET_H #define SHEET_H #include <qtable.h> #include <qstack.h> typedef struct typeCellBorders { QPen right, bottom; }; typedef struct typeCellData { int col, row; typeCellBorders borders; QBrush background; Qt::AlignmentFlags alignment; QColor fontColor; QFont font; QString data; }; class Sheet: public QTable { Q_OBJECT // Variables bool clicksLocked; int selectionNo; typeCellBorders defaultBorders; typeCellData defaultCellData; // QT objects QList<typeCellData> sheetData, clipboardData; QString pressedCell, releasedCell, sheetName; // Private functions int getOperatorPriority(char oper); bool findRowColumn(const QString &variable, int *row, int *col, bool giveError=FALSE); bool findRange(const QString &variable1, const QString &variable2, int *row1, int *col1, int *row2, int *col2); double calculateVariable(const QString &variable); double calculateFunction(const QString &function, const QString ¶meters); QChar popCharStack(QStack<QChar> *stackChars); QString popStringStack(QStack<QString> *stackStrings); QString getParameter(const QString ¶meters, int paramNo, bool giveError=FALSE, const QString funcName=""); QString dataParser(const QString &data); QString dataParserHelper(const QString &data); typeCellData *createCellData(int row, int col); typeCellData *findCellData(int row, int col); void pushCharStack(QStack<QChar> *stackChars, const QChar &character); void pushStringStack(QStack<QString> *stackStrings, const QString &string); // Sheet/Qt parser functions double functionSum(const QString ¶m1, const QString ¶m2); double functionAvg(const QString ¶m1, const QString ¶m2); double functionMax(const QString ¶m1, const QString ¶m2); double functionMin(const QString ¶m1, const QString ¶m2); double functionCount(const QString ¶m1, const QString ¶m2); // Reimplemented QTable functions void paintCell(QPainter *p, int row, int col, const QRect & cr, bool selected); void viewportMousePressEvent(QMouseEvent *e); void viewportMouseMoveEvent(QMouseEvent *e); void viewportMouseReleaseEvent(QMouseEvent *e); private slots: void slotCellSelected(int row, int col); void slotCellChanged(int row, int col); public: Sheet(int numRows, int numCols, QWidget *parent); ~Sheet(); void setData(const QString &data); QString getData(); void setName(const QString &data); QString getName(); void setPen(int row, int col, int vertical, const QPen &pen); QPen getPen(int row, int col, int vertical); void setBrush(int row, int col, const QBrush &brush); QBrush getBrush(int row, int col); void setTextAlign(int row, int col, Qt::AlignmentFlags flags); Qt::AlignmentFlags getAlignment(int row, int col); void setTextFont(int row, int col, const QFont &font, const QColor &color); QFont getFont(int row, int col); QColor getFontColor(int row, int col); void lockClicks(bool lock=TRUE); void copySheetData(QList<typeCellData> *destSheetData); void setSheetData(QList<typeCellData> *srcSheetData); void getSelection(int *row1, int *col1, int *row2, int *col2); diff --git a/noncore/apps/opie-sheet/sortdlg.cpp b/noncore/apps/opie-sheet/sortdlg.cpp index f46562e..4f18fd3 100644 --- a/noncore/apps/opie-sheet/sortdlg.cpp +++ b/noncore/apps/opie-sheet/sortdlg.cpp @@ -1,96 +1,110 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #include <qlabel.h> #include <qradiobutton.h> #include <qmessagebox.h> #include "sortdlg.h" SortDialog::SortDialog(QWidget *parent=0) :QDialog(parent, 0, TRUE) { // Main widget tabs=new QTabWidget(this); widgetSort=new QWidget(tabs); widgetOptions=new QWidget(tabs); tabs->addTab(widgetSort, tr("&Sort")); tabs->addTab(widgetOptions, tr("&Options")); // Sort tab comboFieldA=createFieldCombo(tr("&Sort by"), 10); groupOrderA=createOrderButtons(10); comboFieldB=createFieldCombo(tr("&Then by"), 90); groupOrderB=createOrderButtons(90); comboFieldC=createFieldCombo(tr("Then &by"), 170); groupOrderC=createOrderButtons(170); // Options tab checkCase=new QCheckBox(tr("&Case Sensitive"), widgetOptions); checkCase->setGeometry(10, 10, 215, 20); checkCase->setChecked(TRUE); groupDirection=new QVButtonGroup(tr("&Direction"), widgetOptions); groupDirection->setGeometry(10, 40, 215, 70); QRadioButton *radio=new QRadioButton(tr("&Top to bottom (rows)"), groupDirection); radio=new QRadioButton(tr("&Left to right (columns)"), groupDirection); groupDirection->setButton(0); connect(groupDirection, SIGNAL(clicked(int)), this, SLOT(directionChanged(int))); // Main widget box=new QVBoxLayout(this); box->addWidget(tabs); setCaption(tr("Sort")); } SortDialog::~SortDialog() { } QComboBox *SortDialog::createFieldCombo(const QString &caption, int y) { QLabel *label=new QLabel(caption, widgetSort); label->setGeometry(10, y+5, 215, 20); QComboBox *combo=new QComboBox(FALSE, widgetSort); combo->setGeometry(10, y+35, 105, 20); label->setBuddy(combo); return combo; } QVButtonGroup *SortDialog::createOrderButtons(int y) { QVButtonGroup *group=new QVButtonGroup(widgetSort); group->setGeometry(125, y, 100, 60); QRadioButton *radio=new QRadioButton(tr("&Ascending"), group); radio=new QRadioButton(tr("&Descending"), group); group->setButton(0); return group; } void SortDialog::directionChanged(int id) { direction=id; fillFieldCombo(comboFieldA); fillFieldCombo(comboFieldB); fillFieldCombo(comboFieldC); } void SortDialog::fillFieldCombo(QComboBox *combo) { combo->clear(); if (direction) for (int row=row1; row<=row2; ++row) combo->insertItem("Row "+QString::number(row+1)); else for (int col=col1; col<=col2; ++col) combo->insertItem("Column "+Sheet::getHeaderString(col+1)); } int SortDialog::exec(Sheet *s) { sheet=s; sheet->getSelection(&row1, &col1, &row2, &col2); direction=0; fillFieldCombo(comboFieldA); fillFieldCombo(comboFieldB); fillFieldCombo(comboFieldC); if (row1==row2 && col1==col2) diff --git a/noncore/apps/opie-sheet/sortdlg.h b/noncore/apps/opie-sheet/sortdlg.h index 2c99f02..b3699a9 100644 --- a/noncore/apps/opie-sheet/sortdlg.h +++ b/noncore/apps/opie-sheet/sortdlg.h @@ -1,45 +1,59 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #ifndef SORTDLG_H #define SORTDLG_H #include <qdialog.h> #include <qtabwidget.h> #include <qlayout.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qpushbutton.h> #include <qvbuttongroup.h> #include "sheet.h" class SortDialog: public QDialog { Q_OBJECT // QT objects QBoxLayout *box; QTabWidget *tabs; QWidget *widgetSort, *widgetOptions; QVButtonGroup *groupOrderA, *groupOrderB, *groupOrderC, *groupDirection; QCheckBox *checkCase; QComboBox *comboFieldA, *comboFieldB, *comboFieldC; // Other objects & variables int row1, col1, row2, col2, direction; Sheet *sheet; // Private functions QVButtonGroup *createOrderButtons(int y); QComboBox *createFieldCombo(const QString &caption, int y); void fillFieldCombo(QComboBox *combo); int compareItems(QTableItem *item1, QTableItem *item2, int descending=0, bool caseSensitive=TRUE); private slots: void directionChanged(int id); public: SortDialog(QWidget *parent=0); ~SortDialog(); int exec(Sheet *s); }; #endif diff --git a/noncore/apps/opie-sheet/textdlg.cpp b/noncore/apps/opie-sheet/textdlg.cpp index 8245fe4..0810eb2 100644 --- a/noncore/apps/opie-sheet/textdlg.cpp +++ b/noncore/apps/opie-sheet/textdlg.cpp @@ -1,32 +1,46 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #include "textdlg.h" TextDialog::TextDialog(QWidget *parent=0) :QDialog(parent, 0, TRUE) { edit=new QLineEdit(this); edit->setGeometry(90, 10, 100, 25); label=new QLabel(this); label->setGeometry(10, 10, 70, 25); label->setBuddy(edit); resize(200, 45); } TextDialog::~TextDialog() { } int TextDialog::exec(const QString &caption, const QString &text, const QString &value="") { setCaption(caption); label->setText(text); edit->setText(value); return QDialog::exec(); } QString TextDialog::getValue() { return edit->text(); } diff --git a/noncore/apps/opie-sheet/textdlg.h b/noncore/apps/opie-sheet/textdlg.h index f948228..78ef580 100644 --- a/noncore/apps/opie-sheet/textdlg.h +++ b/noncore/apps/opie-sheet/textdlg.h @@ -1,24 +1,38 @@ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +/* + * Opie Sheet (formerly Sheet/Qt) + * by Serdar Ozler <sozler@sitebest.com> + */ + #ifndef TEXTDLG_H #define TEXTDLG_H #include <qdialog.h> #include <qlabel.h> #include <qlineedit.h> class TextDialog: public QDialog { Q_OBJECT // QT objects QLabel *label; QLineEdit *edit; public: TextDialog(QWidget *parent=0); ~TextDialog(); int exec(const QString &caption, const QString &text, const QString &value=""); QString getValue(); }; #endif |