Git commit 28b93b71eee884de94a94068da36ba5f15efe75b by Alexander Semke, on = behalf of Garvit Khatri. Committed on 21/02/2015 at 09:12. Pushed by asemke into branch 'frameworks'. Backend ported but with kdelibs4support M +1 -0 CMakeLists.txt M +1 -1 src/CMakeLists.txt M +2 -2 src/backend/worksheet/StandardCurveSymbolFactory.cpp M +1 -1 src/backend/worksheet/TextLabel.cpp M +1 -1 src/backend/worksheet/interfaces.h M +2 -2 src/backend/worksheet/plots/cartesian/CartesianCoordinateSys= tem.h M +1155 -1154 src/commonfrontend/spreadsheet/SpreadsheetView.cpp M +1269 -1269 src/commonfrontend/worksheet/WorksheetView.cpp M +1 -1 src/kdefrontend/GuiObserver.cpp M +6 -6 src/kdefrontend/MainWin.cpp M +2 -2 src/kdefrontend/SettingsDialog.cpp M +3 -2 src/kdefrontend/SettingsGeneralPage.cpp M +2 -3 src/kdefrontend/TemplateHandler.cpp M +1 -1 src/tools/TeXRenderer.cpp http://commits.kde.org/labplot/28b93b71eee884de94a94068da36ba5f15efe75b diff --git a/CMakeLists.txt b/CMakeLists.txt index b91878f..a5bdb00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ find_package(KF5 REQUIRED COMPONENTS XmlGui KIO NotifyConfig + Declarative KDELibs4Support) = include(FeatureSummary) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 847124f..602675d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -164,7 +164,7 @@ set(LABPLOT_SRCS ${GUI_SOURCES} ${PLOTS_SOURCES}) INCLUDE_DIRECTORIES(.) qt5_wrap_ui(LABPLOT_SRCS ${UI_SOURCES}) add_executable(labplot2 ${LABPLOT_SRCS} ${BACKEND_SOURCES} ${DATASOURCES_S= OURCES} ${COMMONFRONTEND_SOURCES} ${TOOLS_SOURCES} ${QTMOC_HDRS}) -target_link_libraries(labplot2 KF5::KDELibs4Support KF5::Archive Qt5::Decl= arative KF5::Declarative KF5::WidgetsAddons KF5::KIOWidgets KF5::XmlGui ${G= SL_LIBRARIES} ${GSL_CBLAS_LIBRARIES}) +target_link_libraries(labplot2 KF5::KDELibs4Support KF5::Archive Qt5::Svg = KF5::Declarative KF5::WidgetsAddons KF5::KIOWidgets KF5::XmlGui ${GSL_LIBRA= RIES} ${GSL_CBLAS_LIBRARIES}) # ${OPJ_LIBRARY} = ############## installation ################################ diff --git a/src/backend/worksheet/StandardCurveSymbolFactory.cpp b/src/bac= kend/worksheet/StandardCurveSymbolFactory.cpp index 87c2a5d..992a0a0 100644 --- a/src/backend/worksheet/StandardCurveSymbolFactory.cpp +++ b/src/backend/worksheet/StandardCurveSymbolFactory.cpp @@ -232,5 +232,5 @@ const AbstractCurveSymbol *StandardCurveSymbolFactory::= prototype(const QString & return NULL; } = -Q_EXPORT_PLUGIN2(scidavis_standardcurvesymbolfactory, StandardCurveSymbolF= actory) -Q_IMPORT_PLUGIN(scidavis_standardcurvesymbolfactory) +//Q_EXPORT_PLUGIN2(scidavis_standardcurvesymbolfactory, StandardCurveSymbo= lFactory) +//Q_IMPORT_PLUGIN(scidavis_standardcurvesymbolfactory) diff --git a/src/backend/worksheet/TextLabel.cpp b/src/backend/worksheet/Te= xtLabel.cpp index eb8d7ed..ab9dafa 100644 --- a/src/backend/worksheet/TextLabel.cpp +++ b/src/backend/worksheet/TextLabel.cpp @@ -33,7 +33,7 @@ #include "backend/lib/XmlStreamReader.h" = #include -#include +#include #include #include #include diff --git a/src/backend/worksheet/interfaces.h b/src/backend/worksheet/int= erfaces.h index eddea4e..6577050 100644 --- a/src/backend/worksheet/interfaces.h +++ b/src/backend/worksheet/interfaces.h @@ -30,7 +30,7 @@ #ifndef WORKSHEET_INTERFACES_H #define WORKSHEET_INTERFACES_H = -#include +//#include #include #include "backend/worksheet/AbstractCurveSymbol.h" = diff --git a/src/backend/worksheet/plots/cartesian/CartesianCoordinateSyste= m.h b/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.h index ce19857..1ddf590 100644 --- a/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.h +++ b/src/backend/worksheet/plots/cartesian/CartesianCoordinateSystem.h @@ -44,8 +44,8 @@ class CartesianCoordinateSystem: public AbstractCoordinat= eSystem { public: class Scale { public: - static const double LIMIT_MAX =3D 1e15; - static const double LIMIT_MIN =3D -1e15; + static constexpr double LIMIT_MAX =3D 1e15; + static constexpr double LIMIT_MIN =3D -1e15; = virtual ~Scale(); enum ScaleType { diff --git a/src/commonfrontend/spreadsheet/SpreadsheetView.cpp b/src/commo= nfrontend/spreadsheet/SpreadsheetView.cpp index 4cd7f93..6669424 100644 --- a/src/commonfrontend/spreadsheet/SpreadsheetView.cpp +++ b/src/commonfrontend/spreadsheet/SpreadsheetView.cpp @@ -54,9 +54,10 @@ #include #include #include +#include // #include = -#include +#include #include #include "kdefrontend/spreadsheet/SortDialog.h" #include "kdefrontend/spreadsheet/RandomValuesDialog.h" @@ -64,181 +65,181 @@ #include "kdefrontend/spreadsheet/FunctionValuesDialog.h" = /*! - \class SpreahsheetView - \brief View class for Spreadsheet + \class SpreahsheetView + \brief View class for Spreadsheet = - \ingroup commonfrontend + \ingroup commonfrontend */ SpreadsheetView::SpreadsheetView(Spreadsheet *spreadsheet):QWidget(), - m_tableView(new QTableView(this)), - m_spreadsheet(spreadsheet), - m_model( new SpreadsheetModel(spreadsheet) ), - m_suppressSelectionChangedEvent(false){ + m_tableView(new QTableView(this)), + m_spreadsheet(spreadsheet), + m_model( new SpreadsheetModel(spreadsheet) ), + m_suppressSelectionChangedEvent(false){ = - QHBoxLayout* layout =3D new QHBoxLayout(this); - layout->setContentsMargins(0,0,0,0); - layout->addWidget(m_tableView); + QHBoxLayout* layout =3D new QHBoxLayout(this); + layout->setContentsMargins(0,0,0,0); + layout->addWidget(m_tableView); = - init(); + init(); } = SpreadsheetView::~SpreadsheetView(){ - delete m_model; + delete m_model; } = void SpreadsheetView::init(){ - initActions(); - initMenus(); + initActions(); + initMenus(); = - m_tableView->setModel(m_model); + m_tableView->setModel(m_model); = - //horizontal header - m_horizontalHeader =3D new SpreadsheetDoubleHeaderView(this); + //horizontal header + m_horizontalHeader =3D new SpreadsheetDoubleHeaderView(this); m_horizontalHeader->setClickable(true); m_horizontalHeader->setHighlightSections(true); - m_tableView->setHorizontalHeader(m_horizontalHeader); - m_horizontalHeader->setResizeMode(QHeaderView::Interactive); - m_horizontalHeader->setMovable(true); - m_horizontalHeader->installEventFilter(this); - connect(m_horizontalHeader, SIGNAL(sectionMoved(int,int,int)), this, SLOT= (handleHorizontalSectionMoved(int,int,int))); - connect(m_horizontalHeader, SIGNAL(sectionDoubleClicked(int)), this, SLOT= (handleHorizontalHeaderDoubleClicked(int))); - connect(m_horizontalHeader, SIGNAL(sectionResized(int,int,int)), this, SL= OT(handleHorizontalSectionResized(int,int,int))); + m_tableView->setHorizontalHeader(m_horizontalHeader); + m_horizontalHeader->setResizeMode(QHeaderView::Interactive); + m_horizontalHeader->setMovable(true); + m_horizontalHeader->installEventFilter(this); + connect(m_horizontalHeader, SIGNAL(sectionMoved(int,int,int)), this, S= LOT(handleHorizontalSectionMoved(int,int,int))); + connect(m_horizontalHeader, SIGNAL(sectionDoubleClicked(int)), this, S= LOT(handleHorizontalHeaderDoubleClicked(int))); + connect(m_horizontalHeader, SIGNAL(sectionResized(int,int,int)), this,= SLOT(handleHorizontalSectionResized(int,int,int))); = - // vertical header - QHeaderView * v_header =3D m_tableView->verticalHeader(); - v_header->setResizeMode(QHeaderView::Fixed); - v_header->setDefaultSectionSize(22); - v_header->setMovable(false); - v_header->installEventFilter(this); + // vertical header + QHeaderView * v_header =3D m_tableView->verticalHeader(); + v_header->setResizeMode(QHeaderView::Fixed); + v_header->setDefaultSectionSize(22); + v_header->setMovable(false); + v_header->installEventFilter(this); = - m_delegate =3D new SpreadsheetItemDelegate(this); - m_tableView->setItemDelegate(m_delegate); + m_delegate =3D new SpreadsheetItemDelegate(this); + m_tableView->setItemDelegate(m_delegate); = - setFocusPolicy(Qt::StrongFocus); - setFocus(); - m_tableView->setSelectionMode(QAbstractItemView::ExtendedSelection); + setFocusPolicy(Qt::StrongFocus); + setFocus(); + m_tableView->setSelectionMode(QAbstractItemView::ExtendedSelection); = = - installEventFilter(this); + installEventFilter(this); = - connect(m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), this, - SLOT(updateHeaderGeometry(Qt::Orientation,int,int)) ); - connect(m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), this, - SLOT(handleHeaderDataChanged(Qt::Orientation,int,int)) ); + connect(m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), t= his, + SLOT(updateHeaderGeometry(Qt::Orientation,int,int)) ); + connect(m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), t= his, + SLOT(handleHeaderDataChanged(Qt::Orientation,int,int)) ); = - int i=3D0; - foreach(Column * col, m_spreadsheet->children()) - m_horizontalHeader->resizeSection(i++, col->width()); + int i=3D0; + foreach(Column * col, m_spreadsheet->children()) + m_horizontalHeader->resizeSection(i++, col->width()); = = - connectActions(); - showComments(false); + connectActions(); + showComments(false); = - connect(m_spreadsheet, SIGNAL(aspectAdded(const AbstractAspect*)), - this, SLOT(handleAspectAdded(const AbstractAspect*))); - connect(m_spreadsheet, SIGNAL(aspectAboutToBeRemoved(const AbstractAspect= *)), - this, SLOT(handleAspectAboutToBeRemoved(const AbstractAspect*))); - connect(m_spreadsheet, SIGNAL(requestProjectContextMenu(QMenu*)), this, S= LOT(createContextMenu(QMenu*))); + connect(m_spreadsheet, SIGNAL(aspectAdded(const AbstractAspect*)), + this, SLOT(handleAspectAdded(const AbstractAspect*))); + connect(m_spreadsheet, SIGNAL(aspectAboutToBeRemoved(const AbstractAsp= ect*)), + this, SLOT(handleAspectAboutToBeRemoved(const AbstractAspect*)= )); + connect(m_spreadsheet, SIGNAL(requestProjectContextMenu(QMenu*)), this= , SLOT(createContextMenu(QMenu*))); = = - //selection relevant connections - QItemSelectionModel * sel_model =3D m_tableView->selectionModel(); + //selection relevant connections + QItemSelectionModel * sel_model =3D m_tableView->selectionModel(); = - connect(sel_model, SIGNAL(currentColumnChanged(QModelIndex,QModelIndex)), - this, SLOT(currentColumnChanged(QModelIndex,QModelIndex))); - connect(sel_model, SIGNAL(selectionChanged(QItemSelection,QItemSelection)= ), - this, SLOT(selectionChanged(QItemSelection,QItemSelection))); - connect(sel_model, SIGNAL(selectionChanged(QItemSelection,QItemSelection)= ), - this, SLOT(selectionChanged(QItemSelection,QItemSelection)) ); + connect(sel_model, SIGNAL(currentColumnChanged(QModelIndex,QModelIndex= )), + this, SLOT(currentColumnChanged(QModelIndex,QModelIndex))); + connect(sel_model, SIGNAL(selectionChanged(QItemSelection,QItemSelecti= on)), + this, SLOT(selectionChanged(QItemSelection,QItemSelection))); + connect(sel_model, SIGNAL(selectionChanged(QItemSelection,QItemSelecti= on)), + this, SLOT(selectionChanged(QItemSelection,QItemSelection)) ); = - connect(m_spreadsheet, SIGNAL(columnSelected(int)), this, SLOT(selectColu= mn(int)) ); - connect(m_spreadsheet, SIGNAL(columnDeselected(int)), this, SLOT(deselect= Column(int)) ); - connect(m_tableView->horizontalHeader(), SIGNAL(sectionClicked(int)), thi= s, SLOT(columnClicked(int)) ); + connect(m_spreadsheet, SIGNAL(columnSelected(int)), this, SLOT(selectC= olumn(int)) ); + connect(m_spreadsheet, SIGNAL(columnDeselected(int)), this, SLOT(desel= ectColumn(int)) ); + connect(m_tableView->horizontalHeader(), SIGNAL(sectionClicked(int)), = this, SLOT(columnClicked(int)) ); } = void SpreadsheetView::initActions(){ - // selection related actions - action_cut_selection =3D new KAction(KIcon("edit-cut"), i18n("Cu&t"), thi= s); - action_copy_selection =3D new KAction(KIcon("edit-copy"), i18n("&Copy"), = this); - action_paste_into_selection =3D new KAction(KIcon("edit-paste"), i18n("Pa= st&e"), this); - action_mask_selection =3D new KAction(KIcon("edit-node"), i18n("&Mask Sel= ection"), this); - action_unmask_selection =3D new KAction(KIcon("format-remove-node"), i18n= ("&Unmask Selection"), this); - - action_set_formula =3D new KAction(KIcon(""), i18n("Assign &Formula"), th= is); - action_clear_selection =3D new KAction(KIcon("edit-clear"), i18n("Clea&r = Selection"), this); - action_recalculate =3D new KAction(KIcon(""), i18n("Recalculate"), this); - action_fill_row_numbers =3D new KAction(KIcon(""), i18n("Row Numbers"), t= his); - action_fill_random =3D new KAction(KIcon(""), i18n("Uniform Random Values= "), this); - action_fill_random_nonuniform =3D new KAction(KIcon(""), i18n("Random Val= ues"), this); - action_fill_equidistant =3D new KAction(KIcon(""), i18n("Equidistant Valu= es"), this); - action_fill_function =3D new KAction(KIcon(""), i18n("Function Values"), = this); - action_fill_const =3D new KAction(KIcon(""), i18n("Const Values"), this); - - //spreadsheet related actions - action_toggle_comments =3D new KAction(KIcon("document-properties"), i18n= ("Show Comments"), this); - action_select_all =3D new KAction(KIcon("edit-select-all"), i18n("Select = All"), this); - action_add_column =3D new KAction(KIcon("edit-table-insert-column-left"),= i18n("&Add Column"), this); - action_clear_spreadsheet =3D new KAction(KIcon("edit-clear"), i18n("Clear= Spreadsheet"), this); - action_clear_masks =3D new KAction(KIcon("format-remove-node"), i18n("Cle= ar Masks"), this); - action_sort_spreadsheet =3D new KAction(KIcon("view-sort-ascending"), i18= n("&Sort Spreadsheet"), this); - action_go_to_cell =3D new KAction(KIcon("go-jump"), i18n("&Go to Cell"), = this); - - // column related actions - action_insert_columns =3D new KAction(KIcon("edit-table-insert-column-lef= t"), i18n("&Insert Empty Columns"), this); - action_remove_columns =3D new KAction(KIcon("edit-table-delete-column"), = i18n("Remo&ve Columns"), this); - action_clear_columns =3D new KAction(KIcon("edit-clear"), i18n("Clea&r Co= lumns"), this); - action_add_columns =3D new KAction(KIcon("edit-table-insert-column-right"= ), i18n("&Add Columns"), this); -// action_set_as_x =3D new KAction(KIcon(""), i18n("X, Plot Designation")= , this); -// action_set_as_y =3D new KAction(KIcon(""), i18n("Y, Plot Designation")= , this); -// action_set_as_z =3D new KAction(KIcon(""), i18n("Z, Plot Designation")= , this); -// action_set_as_xerr =3D new KAction(KIcon(""), i18n("X Error, Plot Desi= gnation"), this); -// action_set_as_yerr =3D new KAction(KIcon(""), i18n("Y Error, Plot Desi= gnation"), this); -// action_set_as_none =3D new KAction(KIcon(""), i18n("None, Plot Designa= tion"), this); - action_normalize_columns =3D new KAction(KIcon(""), i18n("&Normalize Colu= mns"), this); - action_normalize_selection =3D new KAction(KIcon(""), i18n("&Normalize Se= lection"), this); - action_sort_columns =3D new KAction(KIcon(""), i18n("&Selected Columns"),= this); - action_sort_asc_column =3D new KAction(KIcon("view-sort-ascending"), i18n= ("&Ascending"), this); - action_sort_desc_column =3D new KAction(KIcon("view-sort-descending"), i1= 8n("&Descending"), this); - action_statistics_columns =3D new KAction(KIcon("view-statistics"), i18n(= "Column Statisti&cs"), this); - - // row related actions - action_insert_rows =3D new KAction(KIcon("edit-table-insert-row-above") ,= i18n("&Insert Empty Rows"), this); - action_remove_rows =3D new KAction(KIcon("edit-table-delete-row"), i18n("= Remo&ve Rows"), this); - action_clear_rows =3D new KAction(KIcon("edit-clear"), i18n("Clea&r Rows"= ), this); - action_add_rows =3D new KAction(KIcon("edit-table-insert-row-above"), i18= n("&Add Rows"), this); - action_statistics_rows =3D new KAction(KIcon("view-statistics"), i18n("Ro= w Statisti&cs"), this); + // selection related actions + action_cut_selection =3D new QAction(QIcon("edit-cut"), i18n("Cu&t"), = this); + action_copy_selection =3D new QAction(QIcon("edit-copy"), i18n("&Copy"= ), this); + action_paste_into_selection =3D new QAction(QIcon("edit-paste"), i18n(= "Past&e"), this); + action_mask_selection =3D new QAction(QIcon("edit-node"), i18n("&Mask = Selection"), this); + action_unmask_selection =3D new QAction(QIcon("format-remove-node"), i= 18n("&Unmask Selection"), this); + + action_set_formula =3D new QAction(QIcon(""), i18n("Assign &Formula"),= this); + action_clear_selection =3D new QAction(QIcon("edit-clear"), i18n("Clea= &r Selection"), this); + action_recalculate =3D new QAction(QIcon(""), i18n("Recalculate"), thi= s); + action_fill_row_numbers =3D new QAction(QIcon(""), i18n("Row Numbers")= , this); + action_fill_random =3D new QAction(QIcon(""), i18n("Uniform Random Val= ues"), this); + action_fill_random_nonuniform =3D new QAction(QIcon(""), i18n("Random = Values"), this); + action_fill_equidistant =3D new QAction(QIcon(""), i18n("Equidistant V= alues"), this); + action_fill_function =3D new QAction(QIcon(""), i18n("Function Values"= ), this); + action_fill_const =3D new QAction(QIcon(""), i18n("Const Values"), thi= s); + + //spreadsheet related actions + action_toggle_comments =3D new QAction(QIcon("document-properties"), i= 18n("Show Comments"), this); + action_select_all =3D new QAction(QIcon("edit-select-all"), i18n("Sele= ct All"), this); + action_add_column =3D new QAction(QIcon("edit-table-insert-column-left= "), i18n("&Add Column"), this); + action_clear_spreadsheet =3D new QAction(QIcon("edit-clear"), i18n("Cl= ear Spreadsheet"), this); + action_clear_masks =3D new QAction(QIcon("format-remove-node"), i18n("= Clear Masks"), this); + action_sort_spreadsheet =3D new QAction(QIcon("view-sort-ascending"), = i18n("&Sort Spreadsheet"), this); + action_go_to_cell =3D new QAction(QIcon("go-jump"), i18n("&Go to Cell"= ), this); + + // column related actions + action_insert_columns =3D new QAction(QIcon("edit-table-insert-column-= left"), i18n("&Insert Empty Columns"), this); + action_remove_columns =3D new QAction(QIcon("edit-table-delete-column"= ), i18n("Remo&ve Columns"), this); + action_clear_columns =3D new QAction(QIcon("edit-clear"), i18n("Clea&r= Columns"), this); + action_add_columns =3D new QAction(QIcon("edit-table-insert-column-rig= ht"), i18n("&Add Columns"), this); +// action_set_as_x =3D new QAction(QIcon(""), i18n("X, Plot Designation")= , this); +// action_set_as_y =3D new QAction(QIcon(""), i18n("Y, Plot Designation")= , this); +// action_set_as_z =3D new QAction(QIcon(""), i18n("Z, Plot Designation")= , this); +// action_set_as_xerr =3D new QAction(QIcon(""), i18n("X Error, Plot Desi= gnation"), this); +// action_set_as_yerr =3D new QAction(QIcon(""), i18n("Y Error, Plot Desi= gnation"), this); +// action_set_as_none =3D new QAction(QIcon(""), i18n("None, Plot Designa= tion"), this); + action_normalize_columns =3D new QAction(QIcon(""), i18n("&Normalize C= olumns"), this); + action_normalize_selection =3D new QAction(QIcon(""), i18n("&Normalize= Selection"), this); + action_sort_columns =3D new QAction(QIcon(""), i18n("&Selected Columns= "), this); + action_sort_asc_column =3D new QAction(QIcon("view-sort-ascending"), i= 18n("&Ascending"), this); + action_sort_desc_column =3D new QAction(QIcon("view-sort-descending"),= i18n("&Descending"), this); + action_statistics_columns =3D new QAction(QIcon("view-statistics"), i1= 8n("Column Statisti&cs"), this); + + // row related actions + action_insert_rows =3D new QAction(QIcon("edit-table-insert-row-above"= ) ,i18n("&Insert Empty Rows"), this); + action_remove_rows =3D new QAction(QIcon("edit-table-delete-row"), i18= n("Remo&ve Rows"), this); + action_clear_rows =3D new QAction(QIcon("edit-clear"), i18n("Clea&r Ro= ws"), this); + action_add_rows =3D new QAction(QIcon("edit-table-insert-row-above"), = i18n("&Add Rows"), this); + action_statistics_rows =3D new QAction(QIcon("view-statistics"), i18n(= "Row Statisti&cs"), this); } = void SpreadsheetView::initMenus(){ - //Selection menu - m_selectionMenu =3D new QMenu(i18n("Selection")); + //Selection menu + m_selectionMenu =3D new QMenu(i18n("Selection")); = - QMenu * submenu =3D new QMenu(i18n("Fi&ll Selection with")); - submenu->addAction(action_fill_row_numbers); - submenu->addAction(action_fill_const); + QMenu * submenu =3D new QMenu(i18n("Fi&ll Selection with")); + submenu->addAction(action_fill_row_numbers); + submenu->addAction(action_fill_const); // submenu->addAction(action_fill_random); - m_selectionMenu ->addMenu(submenu); - m_selectionMenu ->addSeparator(); - - m_selectionMenu ->addAction(action_cut_selection); - m_selectionMenu ->addAction(action_copy_selection); - m_selectionMenu ->addAction(action_paste_into_selection); - m_selectionMenu ->addAction(action_clear_selection); - m_selectionMenu ->addSeparator(); - m_selectionMenu ->addAction(action_mask_selection); - m_selectionMenu ->addAction(action_unmask_selection); - m_selectionMenu ->addSeparator(); - m_selectionMenu ->addAction(action_normalize_selection); - //TODO + m_selectionMenu ->addMenu(submenu); + m_selectionMenu ->addSeparator(); + + m_selectionMenu ->addAction(action_cut_selection); + m_selectionMenu ->addAction(action_copy_selection); + m_selectionMenu ->addAction(action_paste_into_selection); + m_selectionMenu ->addAction(action_clear_selection); + m_selectionMenu ->addSeparator(); + m_selectionMenu ->addAction(action_mask_selection); + m_selectionMenu ->addAction(action_unmask_selection); + m_selectionMenu ->addSeparator(); + m_selectionMenu ->addAction(action_normalize_selection); + //TODO // m_selectionMenu ->addSeparator(); // m_selectionMenu ->addAction(action_set_formula); // m_selectionMenu ->addAction(action_recalculate); = = - //TODO add plot menu to spreadsheet- and column-menu, like in scidavis, o= rigin etc. + //TODO add plot menu to spreadsheet- and column-menu, like in scidavis= , origin etc. = - // Column menu - m_columnMenu =3D new QMenu(); + // Column menu + m_columnMenu =3D new QMenu(); = // submenu =3D new QMenu(i18n("S&et Column As")); // submenu->addAction(action_set_as_x); @@ -252,138 +253,138 @@ void SpreadsheetView::initMenus(){ // m_columnMenu->addMenu(submenu); // m_columnMenu->addSeparator(); = - submenu =3D new QMenu(i18n("Generate Data")); - submenu->addAction(action_fill_row_numbers); - submenu->addAction(action_fill_const); + submenu =3D new QMenu(i18n("Generate Data")); + submenu->addAction(action_fill_row_numbers); + submenu->addAction(action_fill_const); // submenu->addAction(action_fill_random); - submenu->addAction(action_fill_equidistant); - submenu->addAction(action_fill_random_nonuniform); - submenu->addAction(action_fill_function); - m_columnMenu->addMenu(submenu); - m_columnMenu->addSeparator(); - - m_columnMenu->addAction(action_insert_columns); - m_columnMenu->addAction(action_remove_columns); - m_columnMenu->addAction(action_clear_columns); - m_columnMenu->addAction(action_add_columns); - m_columnMenu->addSeparator(); - - m_columnMenu->addAction(action_normalize_columns); - - submenu =3D new QMenu(i18n("Sort")); - submenu->setIcon(KIcon("view-sort-ascending")); - submenu->addAction(action_sort_asc_column); - submenu->addAction(action_sort_desc_column); - submenu->addAction(action_sort_columns); - m_columnMenu->addMenu(submenu); - m_columnMenu->addSeparator(); - - m_columnMenu->addAction(action_toggle_comments); - m_columnMenu->addSeparator(); - - //TODO + submenu->addAction(action_fill_equidistant); + submenu->addAction(action_fill_random_nonuniform); + submenu->addAction(action_fill_function); + m_columnMenu->addMenu(submenu); + m_columnMenu->addSeparator(); + + m_columnMenu->addAction(action_insert_columns); + m_columnMenu->addAction(action_remove_columns); + m_columnMenu->addAction(action_clear_columns); + m_columnMenu->addAction(action_add_columns); + m_columnMenu->addSeparator(); + + m_columnMenu->addAction(action_normalize_columns); + + submenu =3D new QMenu(i18n("Sort")); + submenu->setIcon(QIcon("view-sort-ascending")); + submenu->addAction(action_sort_asc_column); + submenu->addAction(action_sort_desc_column); + submenu->addAction(action_sort_columns); + m_columnMenu->addMenu(submenu); + m_columnMenu->addSeparator(); + + m_columnMenu->addAction(action_toggle_comments); + m_columnMenu->addSeparator(); + + //TODO // m_columnMenu->addAction(action_statistics_columns); = = - //Spreadsheet menu - m_spreadsheetMenu =3D new QMenu(); + //Spreadsheet menu + m_spreadsheetMenu =3D new QMenu(); // m_selectionMenu->setTitle(i18n("Fi&ll Selection with")); - m_spreadsheetMenu->addMenu(m_selectionMenu); - m_spreadsheetMenu->addAction(action_toggle_comments); - m_spreadsheetMenu->addSeparator(); - m_spreadsheetMenu->addAction(action_select_all); - m_spreadsheetMenu->addAction(action_clear_spreadsheet); - m_spreadsheetMenu->addAction(action_clear_masks); - m_spreadsheetMenu->addAction(action_sort_spreadsheet); - m_spreadsheetMenu->addSeparator(); - m_spreadsheetMenu->addAction(action_add_column); - m_spreadsheetMenu->addSeparator(); - m_spreadsheetMenu->addAction(action_go_to_cell); - - - //Row menu - m_rowMenu =3D new QMenu(); - - m_rowMenu->addAction(action_insert_rows); - m_rowMenu->addAction(action_remove_rows); - m_rowMenu->addAction(action_clear_rows); - m_rowMenu->addAction(action_add_rows); - m_rowMenu->addSeparator(); - - submenu =3D new QMenu(i18n("Fi&ll Selection with")); - submenu->addAction(action_fill_row_numbers); + m_spreadsheetMenu->addMenu(m_selectionMenu); + m_spreadsheetMenu->addAction(action_toggle_comments); + m_spreadsheetMenu->addSeparator(); + m_spreadsheetMenu->addAction(action_select_all); + m_spreadsheetMenu->addAction(action_clear_spreadsheet); + m_spreadsheetMenu->addAction(action_clear_masks); + m_spreadsheetMenu->addAction(action_sort_spreadsheet); + m_spreadsheetMenu->addSeparator(); + m_spreadsheetMenu->addAction(action_add_column); + m_spreadsheetMenu->addSeparator(); + m_spreadsheetMenu->addAction(action_go_to_cell); + + + //Row menu + m_rowMenu =3D new QMenu(); + + m_rowMenu->addAction(action_insert_rows); + m_rowMenu->addAction(action_remove_rows); + m_rowMenu->addAction(action_clear_rows); + m_rowMenu->addAction(action_add_rows); + m_rowMenu->addSeparator(); + + submenu =3D new QMenu(i18n("Fi&ll Selection with")); + submenu->addAction(action_fill_row_numbers); // submenu->addAction(action_fill_random); - submenu->addAction(action_fill_const); - m_rowMenu->addMenu(submenu); + submenu->addAction(action_fill_const); + m_rowMenu->addMenu(submenu); = - //TODO + //TODO // m_rowMenu->addSeparator(); // m_rowMenu->addAction(action_statistics_rows); } = void SpreadsheetView::connectActions(){ - connect(action_cut_selection, SIGNAL(triggered()), this, SLOT(cutSelectio= n())); - connect(action_copy_selection, SIGNAL(triggered()), this, SLOT(copySelect= ion())); - connect(action_paste_into_selection, SIGNAL(triggered()), this, SLOT(past= eIntoSelection())); - connect(action_mask_selection, SIGNAL(triggered()), this, SLOT(maskSelect= ion())); - connect(action_unmask_selection, SIGNAL(triggered()), this, SLOT(unmaskSe= lection())); - - connect(action_clear_selection, SIGNAL(triggered()), this, SLOT(clearSele= ctedCells())); - connect(action_recalculate, SIGNAL(triggered()), this, SLOT(recalculateSe= lectedCells())); - connect(action_fill_row_numbers, SIGNAL(triggered()), this, SLOT(fillSele= ctedCellsWithRowNumbers())); + connect(action_cut_selection, SIGNAL(triggered()), this, SLOT(cutSelec= tion())); + connect(action_copy_selection, SIGNAL(triggered()), this, SLOT(copySel= ection())); + connect(action_paste_into_selection, SIGNAL(triggered()), this, SLOT(p= asteIntoSelection())); + connect(action_mask_selection, SIGNAL(triggered()), this, SLOT(maskSel= ection())); + connect(action_unmask_selection, SIGNAL(triggered()), this, SLOT(unmas= kSelection())); + + connect(action_clear_selection, SIGNAL(triggered()), this, SLOT(clearS= electedCells())); + connect(action_recalculate, SIGNAL(triggered()), this, SLOT(recalculat= eSelectedCells())); + connect(action_fill_row_numbers, SIGNAL(triggered()), this, SLOT(fillS= electedCellsWithRowNumbers())); // connect(action_fill_random, SIGNAL(triggered()), this, SLOT(fillSelect= edCellsWithRandomNumbers())); - connect(action_fill_random_nonuniform, SIGNAL(triggered()), this, SLOT(fi= llWithRandomValues())); - connect(action_fill_equidistant, SIGNAL(triggered()), this, SLOT(fillWith= EquidistantValues())); - connect(action_fill_function, SIGNAL(triggered()), this, SLOT(fillWithFun= ctionValues())); - connect(action_fill_const, SIGNAL(triggered()), this, SLOT(fillSelectedCe= llsWithConstValues())); - connect(action_select_all, SIGNAL(triggered()), m_tableView, SLOT(selectA= ll())); - connect(action_add_column, SIGNAL(triggered()), m_spreadsheet, SLOT(appen= dColumn())); - connect(action_clear_spreadsheet, SIGNAL(triggered()), m_spreadsheet, SLO= T(clear())); - connect(action_clear_masks, SIGNAL(triggered()), m_spreadsheet, SLOT(clea= rMasks())); - connect(action_sort_spreadsheet, SIGNAL(triggered()), this, SLOT(sortSpre= adsheet())); - connect(action_go_to_cell, SIGNAL(triggered()), this, SLOT(goToCell())); - - connect(action_insert_columns, SIGNAL(triggered()), this, SLOT(insertEmpt= yColumns())); - connect(action_remove_columns, SIGNAL(triggered()), this, SLOT(removeSele= ctedColumns())); - connect(action_clear_columns, SIGNAL(triggered()), this, SLOT(clearSelect= edColumns())); - connect(action_add_columns, SIGNAL(triggered()), this, SLOT(addColumns())= ); + connect(action_fill_random_nonuniform, SIGNAL(triggered()), this, SLOT= (fillWithRandomValues())); + connect(action_fill_equidistant, SIGNAL(triggered()), this, SLOT(fillW= ithEquidistantValues())); + connect(action_fill_function, SIGNAL(triggered()), this, SLOT(fillWith= FunctionValues())); + connect(action_fill_const, SIGNAL(triggered()), this, SLOT(fillSelecte= dCellsWithConstValues())); + connect(action_select_all, SIGNAL(triggered()), m_tableView, SLOT(sele= ctAll())); + connect(action_add_column, SIGNAL(triggered()), m_spreadsheet, SLOT(ap= pendColumn())); + connect(action_clear_spreadsheet, SIGNAL(triggered()), m_spreadsheet, = SLOT(clear())); + connect(action_clear_masks, SIGNAL(triggered()), m_spreadsheet, SLOT(c= learMasks())); + connect(action_sort_spreadsheet, SIGNAL(triggered()), this, SLOT(sortS= preadsheet())); + connect(action_go_to_cell, SIGNAL(triggered()), this, SLOT(goToCell())= ); + + connect(action_insert_columns, SIGNAL(triggered()), this, SLOT(insertE= mptyColumns())); + connect(action_remove_columns, SIGNAL(triggered()), this, SLOT(removeS= electedColumns())); + connect(action_clear_columns, SIGNAL(triggered()), this, SLOT(clearSel= ectedColumns())); + connect(action_add_columns, SIGNAL(triggered()), this, SLOT(addColumns= ())); // connect(action_set_as_x, SIGNAL(triggered()), this, SLOT(setSelectedCo= lumnsAsX())); // connect(action_set_as_y, SIGNAL(triggered()), this, SLOT(setSelectedCo= lumnsAsY())); // connect(action_set_as_z, SIGNAL(triggered()), this, SLOT(setSelectedCo= lumnsAsZ())); // connect(action_set_as_xerr, SIGNAL(triggered()), this, SLOT(setSelecte= dColumnsAsXError())); // connect(action_set_as_yerr, SIGNAL(triggered()), this, SLOT(setSelecte= dColumnsAsYError())); // connect(action_set_as_none, SIGNAL(triggered()), this, SLOT(setSelecte= dColumnsAsNone())); - connect(action_normalize_columns, SIGNAL(triggered()), this, SLOT(normali= zeSelectedColumns())); - connect(action_normalize_selection, SIGNAL(triggered()), this, SLOT(norma= lizeSelection())); - connect(action_sort_columns, SIGNAL(triggered()), this, SLOT(sortSelected= Columns())); - connect(action_sort_asc_column, SIGNAL(triggered()), this, SLOT(sortColum= nAscending())); - connect(action_sort_desc_column, SIGNAL(triggered()), this, SLOT(sortColu= mnDescending())); - connect(action_statistics_columns, SIGNAL(triggered()), this, SLOT(statis= ticsOnSelectedColumns())); + connect(action_normalize_columns, SIGNAL(triggered()), this, SLOT(norm= alizeSelectedColumns())); + connect(action_normalize_selection, SIGNAL(triggered()), this, SLOT(no= rmalizeSelection())); + connect(action_sort_columns, SIGNAL(triggered()), this, SLOT(sortSelec= tedColumns())); + connect(action_sort_asc_column, SIGNAL(triggered()), this, SLOT(sortCo= lumnAscending())); + connect(action_sort_desc_column, SIGNAL(triggered()), this, SLOT(sortC= olumnDescending())); + connect(action_statistics_columns, SIGNAL(triggered()), this, SLOT(sta= tisticsOnSelectedColumns())); = - connect(action_insert_rows, SIGNAL(triggered()), this, SLOT(insertEmptyRo= ws())); - connect(action_remove_rows, SIGNAL(triggered()), this, SLOT(removeSelecte= dRows())); - connect(action_clear_rows, SIGNAL(triggered()), this, SLOT(clearSelectedR= ows())); - connect(action_add_rows, SIGNAL(triggered()), this, SLOT(addRows())); - connect(action_statistics_rows, SIGNAL(triggered()), this, SLOT(statistic= sOnSelectedRows())); - connect(action_toggle_comments, SIGNAL(triggered()), this, SLOT(toggleCom= ments())); + connect(action_insert_rows, SIGNAL(triggered()), this, SLOT(insertEmpt= yRows())); + connect(action_remove_rows, SIGNAL(triggered()), this, SLOT(removeSele= ctedRows())); + connect(action_clear_rows, SIGNAL(triggered()), this, SLOT(clearSelect= edRows())); + connect(action_add_rows, SIGNAL(triggered()), this, SLOT(addRows())); + connect(action_statistics_rows, SIGNAL(triggered()), this, SLOT(statis= ticsOnSelectedRows())); + connect(action_toggle_comments, SIGNAL(triggered()), this, SLOT(toggle= Comments())); } = void SpreadsheetView::fillToolBar(QToolBar* toolBar){ - toolBar->addAction(action_insert_rows); - toolBar->addAction(action_add_rows); - toolBar->addAction(action_remove_rows); + toolBar->addAction(action_insert_rows); + toolBar->addAction(action_add_rows); + toolBar->addAction(action_remove_rows); // toolBar->addAction(action_statistics_rows); = - toolBar->addSeparator(); - toolBar->addAction(action_insert_columns); - toolBar->addAction(action_add_column); - toolBar->addAction(action_remove_columns); - //TODO + toolBar->addSeparator(); + toolBar->addAction(action_insert_columns); + toolBar->addAction(action_add_column); + toolBar->addAction(action_remove_columns); + //TODO // toolBar->addAction(action_statistics_columns); = - toolBar->addSeparator(); - toolBar->addAction(action_sort_asc_column); - toolBar->addAction(action_sort_desc_column); + toolBar->addSeparator(); + toolBar->addAction(action_sort_asc_column); + toolBar->addAction(action_sort_desc_column); } = /*! @@ -394,150 +395,150 @@ void SpreadsheetView::fillToolBar(QToolBar* toolBar= ){ * - as a part of the spreadsheet context menu in project explorer */ void SpreadsheetView::createContextMenu(QMenu * menu) const { - Q_ASSERT(menu); + Q_ASSERT(menu); = #ifdef ACTIVATE_SCIDAVIS_SPECIFIC_CODE - QAction* firstAction =3D menu->actions().first(); + QAction* firstAction =3D menu->actions().first(); #else - QAction* firstAction =3D 0; - // if we're populating the context menu for the project explorer, then - //there're already actions available there. Skip the first title-action - //and insert the action at the beginning of the menu. - if (menu->actions().size()>1) - firstAction =3D menu->actions().at(1); + QAction* firstAction =3D 0; + // if we're populating the context menu for the project explorer, then + //there're already actions available there. Skip the first title-action + //and insert the action at the beginning of the menu. + if (menu->actions().size()>1) + firstAction =3D menu->actions().at(1); #endif = - menu->insertMenu(firstAction, m_selectionMenu); - menu->insertAction(firstAction, action_toggle_comments); - menu->insertSeparator(firstAction); - menu->insertAction(firstAction, action_select_all); - menu->insertAction(firstAction, action_clear_spreadsheet); - menu->insertAction(firstAction, action_clear_masks); - menu->insertAction(firstAction, action_sort_spreadsheet); - menu->insertSeparator(firstAction); - menu->insertAction(firstAction, action_add_column); - menu->insertSeparator(firstAction); - menu->insertAction(firstAction, action_go_to_cell); - menu->insertSeparator(firstAction); + menu->insertMenu(firstAction, m_selectionMenu); + menu->insertAction(firstAction, action_toggle_comments); + menu->insertSeparator(firstAction); + menu->insertAction(firstAction, action_select_all); + menu->insertAction(firstAction, action_clear_spreadsheet); + menu->insertAction(firstAction, action_clear_masks); + menu->insertAction(firstAction, action_sort_spreadsheet); + menu->insertSeparator(firstAction); + menu->insertAction(firstAction, action_add_column); + menu->insertSeparator(firstAction); + menu->insertAction(firstAction, action_go_to_cell); + menu->insertSeparator(firstAction); = - // TODO - // Export to ASCII - //Export to latex + // TODO + // Export to ASCII + //Export to latex } = //SLOTS void SpreadsheetView::handleAspectAdded(const AbstractAspect * aspect){ - const Column * col =3D qobject_cast(aspect); - if (!col || col->parentAspect() !=3D static_cast(m_sprea= dsheet)) - return; - connect(col, SIGNAL(widthChanged(const Column*)), this, SLOT(updateSectio= nSize(const Column*))); + const Column * col =3D qobject_cast(aspect); + if (!col || col->parentAspect() !=3D static_cast(m_sp= readsheet)) + return; + connect(col, SIGNAL(widthChanged(const Column*)), this, SLOT(updateSec= tionSize(const Column*))); } = void SpreadsheetView::handleAspectAboutToBeRemoved(const AbstractAspect * = aspect){ - const Column * col =3D qobject_cast(aspect); - if (!col || col->parentAspect() !=3D static_cast(m_sprea= dsheet)) - return; - disconnect(col, 0, this, 0); + const Column * col =3D qobject_cast(aspect); + if (!col || col->parentAspect() !=3D static_cast(m_sp= readsheet)) + return; + disconnect(col, 0, this, 0); } = void SpreadsheetView::updateSectionSize(const Column* col){ - disconnect(m_horizontalHeader, SIGNAL(sectionResized(int,int,int)), this,= SLOT(handleHorizontalSectionResized(int,int,int))); - m_horizontalHeader->resizeSection(m_spreadsheet->indexOfChild(col= ), col->width()); - connect(m_horizontalHeader, SIGNAL(sectionResized(int,int,int)), this, SL= OT(handleHorizontalSectionResized(int,int,int))); + disconnect(m_horizontalHeader, SIGNAL(sectionResized(int,int,int)), th= is, SLOT(handleHorizontalSectionResized(int,int,int))); + m_horizontalHeader->resizeSection(m_spreadsheet->indexOfChild(= col), col->width()); + connect(m_horizontalHeader, SIGNAL(sectionResized(int,int,int)), this,= SLOT(handleHorizontalSectionResized(int,int,int))); } = //TODO what for?!? void SpreadsheetView::handleHorizontalSectionResized(int logicalIndex, int= oldSize, int newSize){ - Q_UNUSED(logicalIndex); - Q_UNUSED(oldSize); - static bool inside =3D false; - if (inside) return; - inside =3D true; + Q_UNUSED(logicalIndex); + Q_UNUSED(oldSize); + static bool inside =3D false; + if (inside) return; + inside =3D true; = - int cols =3D m_spreadsheet->columnCount(); - for (int i=3D0; iresizeSection(i, newSize); + int cols =3D m_spreadsheet->columnCount(); + for (int i=3D0; iresizeSection(i, newSize); = - inside =3D false; + inside =3D false; } = /*! Advance current cell after [Return] or [Enter] was pressed. */ void SpreadsheetView::advanceCell(){ - QModelIndex idx =3D m_tableView->currentIndex(); + QModelIndex idx =3D m_tableView->currentIndex(); if (idx.row()+1 >=3D m_spreadsheet->rowCount()) { - int new_size =3D m_spreadsheet->rowCount()+1; - m_spreadsheet->setRowCount(new_size); - } - m_tableView->setCurrentIndex(idx.sibling(idx.row()+1, idx.column())); + int new_size =3D m_spreadsheet->rowCount()+1; + m_spreadsheet->setRowCount(new_size); + } + m_tableView->setCurrentIndex(idx.sibling(idx.row()+1, idx.column())); } = void SpreadsheetView::goToCell(int row, int col){ - QModelIndex index =3D m_model->index(row, col); - m_tableView->scrollTo(index); - m_tableView->setCurrentIndex(index); + QModelIndex index =3D m_model->index(row, col); + m_tableView->scrollTo(index); + m_tableView->setCurrentIndex(index); } = void SpreadsheetView::handleHorizontalSectionMoved(int index, int from, in= t to){ - Q_UNUSED(index); + Q_UNUSED(index); = - static bool inside =3D false; - if (inside) return; + static bool inside =3D false; + if (inside) return; = - Q_ASSERT(index =3D=3D from); + Q_ASSERT(index =3D=3D from); = - inside =3D true; - m_tableView->horizontalHeader()->moveSection(to, from); - inside =3D false; - m_spreadsheet->moveColumn(from, to); + inside =3D true; + m_tableView->horizontalHeader()->moveSection(to, from); + inside =3D false; + m_spreadsheet->moveColumn(from, to); } = //TODO Implement the "change of the column name"-mode upon a double click void SpreadsheetView::handleHorizontalHeaderDoubleClicked(int index){ - Q_UNUSED(index); + Q_UNUSED(index); } = /*! Returns whether comments are show currently or not. */ bool SpreadsheetView::areCommentsShown() const{ - return m_horizontalHeader->areCommentsShown(); + return m_horizontalHeader->areCommentsShown(); } = /*! toggles the column comment in the horizontal header */ void SpreadsheetView::toggleComments(){ - showComments(!areCommentsShown()); - //TODO - if(areCommentsShown()) - action_toggle_comments->setText(i18n("Hide Comments")); - else - action_toggle_comments->setText(i18n("Show Comments")); + showComments(!areCommentsShown()); + //TODO + if(areCommentsShown()) + action_toggle_comments->setText(i18n("Hide Comments")); + else + action_toggle_comments->setText(i18n("Show Comments")); } = //! Shows (\c on=3Dtrue) or hides (\c on=3Dfalse) the column comments in t= he horizontal header void SpreadsheetView::showComments(bool on){ - m_horizontalHeader->showComments(on); + m_horizontalHeader->showComments(on); } = void SpreadsheetView::currentColumnChanged(const QModelIndex & current, co= nst QModelIndex & previous){ - Q_UNUSED(previous); - int col =3D current.column(); - if (col < 0 || col >=3D m_spreadsheet->columnCount()) - return; + Q_UNUSED(previous); + int col =3D current.column(); + if (col < 0 || col >=3D m_spreadsheet->columnCount()) + return; } = //TODO void SpreadsheetView::handleHeaderDataChanged(Qt::Orientation orientation,= int first, int last){ - if (orientation !=3D Qt::Horizontal) return; + if (orientation !=3D Qt::Horizontal) return; = - QItemSelectionModel * sel_model =3D m_tableView->selectionModel(); + QItemSelectionModel * sel_model =3D m_tableView->selectionModel(); = - int col =3D sel_model->currentIndex().column(); - if (col < first || col > last) return; + int col =3D sel_model->currentIndex().column(); + if (col < first || col > last) return; } = /*! @@ -545,23 +546,23 @@ void SpreadsheetView::handleHeaderDataChanged(Qt::Ori= entation orientation, int f If \c full is \c true, this function only returns the number of fully se= lected columns. */ int SpreadsheetView::selectedColumnCount(bool full){ - int count =3D 0; - int cols =3D m_spreadsheet->columnCount(); - for (int i=3D0; icolumnCount(); + for (int i=3D0; icolumnCount(); - for (int i=3D0; icolumn(i)->plotDesign= ation() =3D=3D pd) ) count++; + int count =3D 0; + int cols =3D m_spreadsheet->columnCount(); + for (int i=3D0; icolumn(i)->plot= Designation() =3D=3D pd) ) count++; = - return count; + return count; } = /*! @@ -569,10 +570,10 @@ int SpreadsheetView::selectedColumnCount(AbstractColu= mn::PlotDesignation pd){ If \param full is \c true, this function only returns true if the whole = column is selected. */ bool SpreadsheetView::isColumnSelected(int col, bool full){ - if (full) - return m_tableView->selectionModel()->isColumnSelected(col, QModelIndex(= )); - else - return m_tableView->selectionModel()->columnIntersectsSelection(col, QMo= delIndex()); + if (full) + return m_tableView->selectionModel()->isColumnSelected(col, QModel= Index()); + else + return m_tableView->selectionModel()->columnIntersectsSelection(co= l, QModelIndex()); } = /*! @@ -580,12 +581,12 @@ bool SpreadsheetView::isColumnSelected(int col, bool = full){ If \param full is true, this function only returns a column if the whole= column is selected. */ QList SpreadsheetView::selectedColumns(bool full){ - QList list; - int cols =3D m_spreadsheet->columnCount(); - for (int i=3D0; icolumn(i); + QList list; + int cols =3D m_spreadsheet->columnCount(); + for (int i=3D0; icolumn(i); = - return list; + return list; } = /*! @@ -593,11 +594,11 @@ QList SpreadsheetView::selectedColumns(bool = full){ If \param full is \c true, this function only returns the number of full= y selected rows. */ int SpreadsheetView::selectedRowCount(bool full){ - int count =3D 0; - int rows =3D m_spreadsheet->rowCount(); - for (int i=3D0; irowCount(); + for (int i=3D0; iselectionModel()->isRowSelected(row, QModelIndex()); - else - return m_tableView->selectionModel()->rowIntersectsSelection(row, QModel= Index()); + if (full) + return m_tableView->selectionModel()->isRowSelected(row, QModelInd= ex()); + else + return m_tableView->selectionModel()->rowIntersectsSelection(row, = QModelIndex()); } = /*! @@ -616,13 +617,13 @@ bool SpreadsheetView::isRowSelected(int row, bool ful= l){ If \param full is \c true, this function only looks for fully selected c= olumns. */ int SpreadsheetView::firstSelectedColumn(bool full){ - int cols =3D m_spreadsheet->columnCount(); - for (int i=3D0; icolumnCount(); + for (int i=3D0; icolumnCount(); - for (int i=3Dcols-1; i>=3D0; i--) - if (isColumnSelected(i, full)) return i; + int cols =3D m_spreadsheet->columnCount(); + for (int i=3Dcols-1; i>=3D0; i--) + if (isColumnSelected(i, full)) return i; = - return -2; + return -2; } = /*! @@ -642,13 +643,13 @@ int SpreadsheetView::lastSelectedColumn(bool full){ If \param full is \c true, this function only looks for fully selected r= ows. */ int SpreadsheetView::firstSelectedRow(bool full){ - int rows =3D m_spreadsheet->rowCount(); - for (int i=3D0; irowCount(); + for (int i=3D0; irowCount(); - for (int i=3Drows-1; i>=3D0; i--) - if (isRowSelected(i, full)) return i; + int rows =3D m_spreadsheet->rowCount(); + for (int i=3Drows-1; i>=3D0; i--) + if (isRowSelected(i, full)) return i; = - return -2; + return -2; } = /*! Return whether a cell is selected */ bool SpreadsheetView::isCellSelected(int row, int col){ - if (row < 0 || col < 0 || row >=3D m_spreadsheet->rowCount() || col >=3D = m_spreadsheet->columnCount()) return false; + if (row < 0 || col < 0 || row >=3D m_spreadsheet->rowCount() || col >= =3D m_spreadsheet->columnCount()) return false; = - return m_tableView->selectionModel()->isSelected(m_model->index(row, col)= ); + return m_tableView->selectionModel()->isSelected(m_model->index(row, c= ol)); } = /*! Get the complete set of selected rows. */ IntervalAttribute SpreadsheetView::selectedRows(bool full){ - IntervalAttribute result; - int rows =3D m_spreadsheet->rowCount(); - for (int i=3D0; i result; + int rows =3D m_spreadsheet->rowCount(); + for (int i=3D0; iselectionModel()->select(m_model->index(row, col), - select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect); + m_tableView->selectionModel()->select(m_model->index(row, col), + select ? QItemSelectionModel::Select : QItemSelectionModel::D= eselect); } = /*! Select/Deselect a range of cells. */ void SpreadsheetView::setCellsSelected(int first_row, int first_col, int l= ast_row, int last_col, bool select){ - QModelIndex top_left =3D m_model->index(first_row, first_col); - QModelIndex bottom_right =3D m_model->index(last_row, last_col); - m_tableView->selectionModel()->select(QItemSelection(top_left, bottom_rig= ht), - select ? QItemSelectionModel::SelectCurrent : QItemSelectionModel::Dese= lect); + QModelIndex top_left =3D m_model->index(first_row, first_col); + QModelIndex bottom_right =3D m_model->index(last_row, last_col); + m_tableView->selectionModel()->select(QItemSelection(top_left, bottom_= right), + select ? QItemSelectionModel::SelectCurrent : QItemSelectionMo= del::Deselect); } = /*! Determine the current cell (-1 if no cell is designated as the current). */ void SpreadsheetView::getCurrentCell(int * row, int * col){ - QModelIndex index =3D m_tableView->selectionModel()->currentIndex(); - if (index.isValid()) { - *row =3D index.row(); - *col =3D index.column(); - }else{ - *row =3D -1; - *col =3D -1; - } + QModelIndex index =3D m_tableView->selectionModel()->currentIndex(); + if (index.isValid()) { + *row =3D index.row(); + *col =3D index.column(); + }else{ + *row =3D -1; + *col =3D -1; + } } = bool SpreadsheetView::eventFilter(QObject* watched, QEvent* event) { - if (event->type() =3D=3D QEvent::ContextMenu){ - QContextMenuEvent *cm_event =3D static_cast(event); - QPoint global_pos =3D cm_event->globalPos(); - if (watched =3D=3D m_tableView->verticalHeader()){ - m_rowMenu->exec(global_pos); - }else if (watched =3D=3D m_horizontalHeader) { - int col =3D m_horizontalHeader->logicalIndexAt(cm_event->pos()); - if (!isColumnSelected(col, true)) { - QItemSelectionModel *sel_model =3D m_tableView->selectionModel(); - sel_model->clearSelection(); - sel_model->select(QItemSelection(m_model->index(0, col, QModelIndex()), - m_model->index(m_model->rowCount()-1, col, QModelIndex())), - QItemSelectionModel::Select); - } - - if (selectedColumns().size()=3D=3D1){ - action_sort_columns->setVisible(false); - action_sort_asc_column->setVisible(true); - action_sort_desc_column->setVisible(true); - }else{ - action_sort_columns->setVisible(true); - action_sort_asc_column->setVisible(false); - action_sort_desc_column->setVisible(false); - } - - //check whether we have non-numeric columns selected and deactivate act= ions for numeric columns - bool numeric =3D true; - foreach(Column* col, selectedColumns()) { - if (col->columnMode() !=3D AbstractColumn::Numeric) { - numeric =3D false; - break; - } - } - action_fill_equidistant->setEnabled(numeric); - action_fill_random_nonuniform->setEnabled(numeric); - action_fill_function->setEnabled(numeric); - - m_columnMenu->exec(global_pos); - }else if (watched =3D=3D this){ - m_spreadsheetMenu->exec(global_pos); - }else{ - return QWidget::eventFilter(watched, event); - } - return true; - } - else - return QWidget::eventFilter(watched, event); + if (event->type() =3D=3D QEvent::ContextMenu){ + QContextMenuEvent *cm_event =3D static_cast(ev= ent); + QPoint global_pos =3D cm_event->globalPos(); + if (watched =3D=3D m_tableView->verticalHeader()){ + m_rowMenu->exec(global_pos); + }else if (watched =3D=3D m_horizontalHeader) { + int col =3D m_horizontalHeader->logicalIndexAt(cm_event->pos()= ); + if (!isColumnSelected(col, true)) { + QItemSelectionModel *sel_model =3D m_tableView->selectionM= odel(); + sel_model->clearSelection(); + sel_model->select(QItemSelection(m_model->index(0, col, QM= odelIndex()), + m_model->index(m_model->rowCount()-1, col, QMo= delIndex())), + QItemSelectionModel::Select); + } + + if (selectedColumns().size()=3D=3D1){ + action_sort_columns->setVisible(false); + action_sort_asc_column->setVisible(true); + action_sort_desc_column->setVisible(true); + }else{ + action_sort_columns->setVisible(true); + action_sort_asc_column->setVisible(false); + action_sort_desc_column->setVisible(false); + } + + //check whether we have non-numeric columns selected and deact= ivate actions for numeric columns + bool numeric =3D true; + foreach(Column* col, selectedColumns()) { + if (col->columnMode() !=3D AbstractColumn::Numeric) { + numeric =3D false; + break; + } + } + action_fill_equidistant->setEnabled(numeric); + action_fill_random_nonuniform->setEnabled(numeric); + action_fill_function->setEnabled(numeric); + + m_columnMenu->exec(global_pos); + }else if (watched =3D=3D this){ + m_spreadsheetMenu->exec(global_pos); + }else{ + return QWidget::eventFilter(watched, event); + } + return true; + } + else + return QWidget::eventFilter(watched, event); } = bool SpreadsheetView::formulaModeActive() const{ - return m_model->formulaModeActive(); + return m_model->formulaModeActive(); } = void SpreadsheetView::activateFormulaMode(bool on){ - m_model->activateFormulaMode(on); + m_model->activateFormulaMode(on); } = void SpreadsheetView::goToNextColumn(){ - if (m_spreadsheet->columnCount() =3D=3D 0) return; + if (m_spreadsheet->columnCount() =3D=3D 0) return; = - QModelIndex idx =3D m_tableView->currentIndex(); - int col =3D idx.column()+1; + QModelIndex idx =3D m_tableView->currentIndex(); + int col =3D idx.column()+1; if (col >=3D m_spreadsheet->columnCount()) - col =3D 0; + col =3D 0; = - m_tableView->setCurrentIndex(idx.sibling(idx.row(), col)); + m_tableView->setCurrentIndex(idx.sibling(idx.row(), col)); } = void SpreadsheetView::goToPreviousColumn(){ - if (m_spreadsheet->columnCount() =3D=3D 0) - return; + if (m_spreadsheet->columnCount() =3D=3D 0) + return; = - QModelIndex idx =3D m_tableView->currentIndex(); - int col =3D idx.column()-1; + QModelIndex idx =3D m_tableView->currentIndex(); + int col =3D idx.column()-1; if (col < 0) - col =3D m_spreadsheet->columnCount()-1; + col =3D m_spreadsheet->columnCount()-1; = - m_tableView->setCurrentIndex(idx.sibling(idx.row(), col)); + m_tableView->setCurrentIndex(idx.sibling(idx.row(), col)); } = void SpreadsheetView::cutSelection(){ - int first =3D firstSelectedRow(); - if ( first < 0 ) - return; + int first =3D firstSelectedRow(); + if ( first < 0 ) + return; = - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: cut selected cells", m_spreadsheet->n= ame())); - copySelection(); - clearSelectedCells(); - m_spreadsheet->endMacro(); - RESET_CURSOR; + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: cut selected cells", m_spreadsheet= ->name())); + copySelection(); + clearSelectedCells(); + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::copySelection(){ - int first_col =3D firstSelectedColumn(false); - if (first_col =3D=3D -1) return; - int last_col =3D lastSelectedColumn(false); - if (last_col =3D=3D -2) return; - int first_row =3D firstSelectedRow(false); - if (first_row =3D=3D -1) return; - int last_row =3D lastSelectedRow(false); - if (last_row =3D=3D -2) return; - int cols =3D last_col - first_col +1; - int rows =3D last_row - first_row +1; - - WAIT_CURSOR; - QString output_str; - - for (int r=3D0; rcolumn(first_col + c); - if (isCellSelected(first_row + r, first_col + c)) - { - if (formulaModeActive()) - { - output_str +=3D col_ptr->formula(first_row + r); - } - else if (col_ptr->columnMode() =3D=3D AbstractColumn::Numeric) - { - Double2StringFilter * out_fltr =3D static_cast= (col_ptr->outputFilter()); - output_str +=3D QLocale().toString(col_ptr->valueAt(first_row + r), - out_fltr->numericFormat(), 16); // copy with max. precision - } - else - { - output_str +=3D m_spreadsheet->column(first_col+c)->asStringColumn()-= >textAt(first_row + r); - } - } - if (c < cols-1) - output_str +=3D '\t'; - } - if (r < rows-1) - output_str +=3D '\n'; - } - QApplication::clipboard()->setText(output_str); - RESET_CURSOR; + int first_col =3D firstSelectedColumn(false); + if (first_col =3D=3D -1) return; + int last_col =3D lastSelectedColumn(false); + if (last_col =3D=3D -2) return; + int first_row =3D firstSelectedRow(false); + if (first_row =3D=3D -1) return; + int last_row =3D lastSelectedRow(false); + if (last_row =3D=3D -2) return; + int cols =3D last_col - first_col +1; + int rows =3D last_row - first_row +1; + + WAIT_CURSOR; + QString output_str; + + for (int r=3D0; rcolumn(first_col + c); + if (isCellSelected(first_row + r, first_col + c)) + { + if (formulaModeActive()) + { + output_str +=3D col_ptr->formula(first_row + r); + } + else if (col_ptr->columnMode() =3D=3D AbstractColumn::Nume= ric) + { + Double2StringFilter * out_fltr =3D static_cast(col_ptr->outputFilter()); + output_str +=3D QLocale().toString(col_ptr->valueAt(fi= rst_row + r), + out_fltr->numericFormat(), 16); // copy with m= ax. precision + } + else + { + output_str +=3D m_spreadsheet->column(first_col+c)->as= StringColumn()->textAt(first_row + r); + } + } + if (c < cols-1) + output_str +=3D '\t'; + } + if (r < rows-1) + output_str +=3D '\n'; + } + QApplication::clipboard()->setText(output_str); + RESET_CURSOR; } = void SpreadsheetView::pasteIntoSelection(){ - if (m_spreadsheet->columnCount() < 1 || m_spreadsheet->rowCount() < 1) - return; - - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: paste from clipboard", m_spreadsheet-= >name())); - const QMimeData * mime_data =3D QApplication::clipboard()->mimeData(); - - if (mime_data->hasFormat("text/plain")){ - int first_col =3D firstSelectedColumn(false); - int last_col =3D lastSelectedColumn(false); - int first_row =3D firstSelectedRow(false); - int last_row =3D lastSelectedRow(false); - int input_row_count =3D 0; - int input_col_count =3D 0; - int rows, cols; - - QString input_str =3D QString(mime_data->data("text/plain")).trimmed(); - QList< QStringList > cellTexts; - QStringList input_rows(input_str.split('\n')); - input_row_count =3D input_rows.count(); - input_col_count =3D 0; - for (int i=3D0; i input_col_count) input_col_count =3D cell= Texts.at(i).count(); - } - - if ( (first_col =3D=3D -1 || first_row =3D=3D -1) || - (last_row =3D=3D first_row && last_col =3D=3D first_col) ) - // if the is no selection or only one cell selected, the - // selection will be expanded to the needed size from the current cell - { - int current_row, current_col; - getCurrentCell(¤t_row, ¤t_col); - if (current_row =3D=3D -1) current_row =3D 0; - if (current_col =3D=3D -1) current_col =3D 0; - setCellSelected(current_row, current_col); - first_col =3D current_col; - first_row =3D current_row; - last_row =3D first_row + input_row_count -1; - last_col =3D first_col + input_col_count -1; - // resize the spreadsheet if necessary - if (last_col >=3D m_spreadsheet->columnCount()) - { - for (int i=3D0; icolumnCount(); i++) - { - Column * new_col =3D new Column(QString::number(i+1), AbstractColumn:= :Text); - new_col->setPlotDesignation(AbstractColumn::Y); - new_col->insertRows(0, m_spreadsheet->rowCount()); - m_spreadsheet->addChild(new_col); - } - } - if (last_row >=3D m_spreadsheet->rowCount()) - m_spreadsheet->appendRows(last_row+1-m_spreadsheet->rowCount()); - // select the rectangle to be pasted in - setCellsSelected(first_row, first_col, last_row, last_col); - } - - rows =3D last_row - first_row + 1; - cols =3D last_col - first_col + 1; - for (int r=3D0; rsetSuppressDataChangedSignal(true); - if (isCellSelected(first_row + r, first_col + c) && (c < cellTexts.at(= r).count()) ) - { - Column * col_ptr =3D m_spreadsheet->column(first_col + c); - if (formulaModeActive()) - { - col_ptr->setFormula(first_row + r, cellTexts.at(r).at(c)); - } - else - col_ptr->asStringColumn()->setTextAt(first_row+r, cellTexts.at(r).at= (c)); - } - } - } - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + if (m_spreadsheet->columnCount() < 1 || m_spreadsheet->rowCount() < 1) + return; + + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: paste from clipboard", m_spreadshe= et->name())); + const QMimeData * mime_data =3D QApplication::clipboard()->mimeData(); + + if (mime_data->hasFormat("text/plain")){ + int first_col =3D firstSelectedColumn(false); + int last_col =3D lastSelectedColumn(false); + int first_row =3D firstSelectedRow(false); + int last_row =3D lastSelectedRow(false); + int input_row_count =3D 0; + int input_col_count =3D 0; + int rows, cols; + + QString input_str =3D QString(mime_data->data("text/plain")).trimm= ed(); + QList< QStringList > cellTexts; + QStringList input_rows(input_str.split('\n')); + input_row_count =3D input_rows.count(); + input_col_count =3D 0; + for (int i=3D0; i input_col_count) input_col_count= =3D cellTexts.at(i).count(); + } + + if ( (first_col =3D=3D -1 || first_row =3D=3D -1) || + (last_row =3D=3D first_row && last_col =3D=3D first_col) ) + // if the is no selection or only one cell selected, the + // selection will be expanded to the needed size from the current = cell + { + int current_row, current_col; + getCurrentCell(¤t_row, ¤t_col); + if (current_row =3D=3D -1) current_row =3D 0; + if (current_col =3D=3D -1) current_col =3D 0; + setCellSelected(current_row, current_col); + first_col =3D current_col; + first_row =3D current_row; + last_row =3D first_row + input_row_count -1; + last_col =3D first_col + input_col_count -1; + // resize the spreadsheet if necessary + if (last_col >=3D m_spreadsheet->columnCount()) + { + for (int i=3D0; icolumnCount();= i++) + { + Column * new_col =3D new Column(QString::number(i+1), = AbstractColumn::Text); + new_col->setPlotDesignation(AbstractColumn::Y); + new_col->insertRows(0, m_spreadsheet->rowCount()); + m_spreadsheet->addChild(new_col); + } + } + if (last_row >=3D m_spreadsheet->rowCount()) + m_spreadsheet->appendRows(last_row+1-m_spreadsheet->rowCou= nt()); + // select the rectangle to be pasted in + setCellsSelected(first_row, first_col, last_row, last_col); + } + + rows =3D last_row - first_row + 1; + cols =3D last_col - first_col + 1; + for (int r=3D0; rsetSuppressDataChangedSignal(true); + if (isCellSelected(first_row + r, first_col + c) && (c < c= ellTexts.at(r).count()) ) + { + Column * col_ptr =3D m_spreadsheet->column(first_col += c); + if (formulaModeActive()) + { + col_ptr->setFormula(first_row + r, cellTexts.at(r)= .at(c)); + } + else + col_ptr->asStringColumn()->setTextAt(first_row+r, = cellTexts.at(r).at(c)); + } + } + } + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::maskSelection(){ - int first =3D firstSelectedRow(); - int last =3D lastSelectedRow(); - if ( first < 0 ) return; - - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: mask selected cells", m_spreadsheet->= name())); - QList list =3D selectedColumns(); - foreach(Column * col_ptr, list) - { - int col =3D m_spreadsheet->indexOfChild(col_ptr); - for (int row=3Dfirst; row<=3Dlast; row++) - if (isCellSelected(row, col)) col_ptr->setMasked(row); - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + int first =3D firstSelectedRow(); + int last =3D lastSelectedRow(); + if ( first < 0 ) return; + + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: mask selected cells", m_spreadshee= t->name())); + QList list =3D selectedColumns(); + foreach(Column * col_ptr, list) + { + int col =3D m_spreadsheet->indexOfChild(col_ptr); + for (int row=3Dfirst; row<=3Dlast; row++) + if (isCellSelected(row, col)) col_ptr->setMasked(row); + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::unmaskSelection(){ - int first =3D firstSelectedRow(); - int last =3D lastSelectedRow(); - if ( first < 0 ) return; - - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: unmask selected cells", m_spreadsheet= ->name())); - QList list =3D selectedColumns(); - foreach(Column * col_ptr, list) { - int col =3D m_spreadsheet->indexOfChild(col_ptr); - for (int row=3Dfirst; row<=3Dlast; row++) - if (isCellSelected(row, col)) col_ptr->setMasked(row, false); - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + int first =3D firstSelectedRow(); + int last =3D lastSelectedRow(); + if ( first < 0 ) return; + + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: unmask selected cells", m_spreadsh= eet->name())); + QList list =3D selectedColumns(); + foreach(Column * col_ptr, list) { + int col =3D m_spreadsheet->indexOfChild(col_ptr); + for (int row=3Dfirst; row<=3Dlast; row++) + if (isCellSelected(row, col)) col_ptr->setMasked(row, false); + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = // TODO void SpreadsheetView::recalculateSelectedCells(){ - QMessageBox::information(0, "info", "not yet implemented"); + QMessageBox::information(0, "info", "not yet implemented"); } = void SpreadsheetView::fillSelectedCellsWithRowNumbers(){ - if (selectedColumnCount() < 1) return; - int first =3D firstSelectedRow(); - int last =3D lastSelectedRow(); - if ( first < 0 ) return; - - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: fill cells with row numbers", m_sprea= dsheet->name())); - foreach(Column* col_ptr, selectedColumns()) { - int col =3D m_spreadsheet->indexOfChild(col_ptr); - col_ptr->setSuppressDataChangedSignal(true); - switch (col_ptr->columnMode()) { - case AbstractColumn::Numeric: - { - QVector results(last-first+1); - for (int row=3Dfirst; row<=3Dlast; row++) - if(isCellSelected(row, col)) - results[row-first] =3D row+1; - else - results[row-first] =3D col_ptr->valueAt(row); - col_ptr->replaceValues(first, results); - break; - } - case AbstractColumn::Text: - { - QStringList results; - for (int row=3Dfirst; row<=3Dlast; row++) - if (isCellSelected(row, col)) - results << QString::number(row+1); - else - results << col_ptr->textAt(row); - col_ptr->replaceTexts(first, results); - break; - } - //TODO: handle other modes - default: break; - } - - col_ptr->setSuppressDataChangedSignal(false); - col_ptr->setChanged(); - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + if (selectedColumnCount() < 1) return; + int first =3D firstSelectedRow(); + int last =3D lastSelectedRow(); + if ( first < 0 ) return; + + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: fill cells with row numbers", m_sp= readsheet->name())); + foreach(Column* col_ptr, selectedColumns()) { + int col =3D m_spreadsheet->indexOfChild(col_ptr); + col_ptr->setSuppressDataChangedSignal(true); + switch (col_ptr->columnMode()) { + case AbstractColumn::Numeric: + { + QVector results(last-first+1); + for (int row=3Dfirst; row<=3Dlast; row++) + if(isCellSelected(row, col)) + results[row-first] =3D row+1; + else + results[row-first] =3D col_ptr->valueAt(row); + col_ptr->replaceValues(first, results); + break; + } + case AbstractColumn::Text: + { + QStringList results; + for (int row=3Dfirst; row<=3Dlast; row++) + if (isCellSelected(row, col)) + results << QString::number(row+1); + else + results << col_ptr->textAt(row); + col_ptr->replaceTexts(first, results); + break; + } + //TODO: handle other modes + default: break; + } + + col_ptr->setSuppressDataChangedSignal(false); + col_ptr->setChanged(); + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::fillSelectedCellsWithRandomNumbers(){ - if (selectedColumnCount() < 1) return; - int first =3D firstSelectedRow(); - int last =3D lastSelectedRow(); - if ( first < 0 ) return; - - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: fill cells with random values", m_spr= eadsheet->name())); - qsrand(QTime::currentTime().msec()); - foreach(Column* col_ptr, selectedColumns()) { - int col =3D m_spreadsheet->indexOfChild(col_ptr); - col_ptr->setSuppressDataChangedSignal(true); - switch (col_ptr->columnMode()) { - case AbstractColumn::Numeric: - { - QVector results(last-first+1); - for (int row=3Dfirst; row<=3Dlast; row++) - if (isCellSelected(row, col)) - results[row-first] =3D double(qrand())/double(RAND_MAX); - else - results[row-first] =3D col_ptr->valueAt(row); - col_ptr->replaceValues(first, results); - break; - } - case AbstractColumn::Text: - { - QStringList results; - for (int row=3Dfirst; row<=3Dlast; row++) - if (isCellSelected(row, col)) - results << QString::number(double(qrand())/double(RAND_MAX)); - else - results << col_ptr->textAt(row); - col_ptr->replaceTexts(first, results); - break; - } - case AbstractColumn::DateTime: - case AbstractColumn::Month: - case AbstractColumn::Day: - { - QList results; - QDate earliestDate(1,1,1); - QDate latestDate(2999,12,31); - QTime midnight(0,0,0,0); - for (int row=3Dfirst; row<=3Dlast; row++) - if (isCellSelected(row, col)) - results << QDateTime( - earliestDate.addDays(((double)qrand())*((double)earliestDate.days= To(latestDate))/((double)RAND_MAX)), - midnight.addMSecs(((qint64)qrand())*1000*60*60*24/RAND_MAX)); - else - results << col_ptr->dateTimeAt(row); - col_ptr->replaceDateTimes(first, results); - break; - } - } - - col_ptr->setSuppressDataChangedSignal(false); - col_ptr->setChanged(); - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + if (selectedColumnCount() < 1) return; + int first =3D firstSelectedRow(); + int last =3D lastSelectedRow(); + if ( first < 0 ) return; + + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: fill cells with random values", m_= spreadsheet->name())); + qsrand(QTime::currentTime().msec()); + foreach(Column* col_ptr, selectedColumns()) { + int col =3D m_spreadsheet->indexOfChild(col_ptr); + col_ptr->setSuppressDataChangedSignal(true); + switch (col_ptr->columnMode()) { + case AbstractColumn::Numeric: + { + QVector results(last-first+1); + for (int row=3Dfirst; row<=3Dlast; row++) + if (isCellSelected(row, col)) + results[row-first] =3D double(qrand())/double(= RAND_MAX); + else + results[row-first] =3D col_ptr->valueAt(row); + col_ptr->replaceValues(first, results); + break; + } + case AbstractColumn::Text: + { + QStringList results; + for (int row=3Dfirst; row<=3Dlast; row++) + if (isCellSelected(row, col)) + results << QString::number(double(qrand())/dou= ble(RAND_MAX)); + else + results << col_ptr->textAt(row); + col_ptr->replaceTexts(first, results); + break; + } + case AbstractColumn::DateTime: + case AbstractColumn::Month: + case AbstractColumn::Day: + { + QList results; + QDate earliestDate(1,1,1); + QDate latestDate(2999,12,31); + QTime midnight(0,0,0,0); + for (int row=3Dfirst; row<=3Dlast; row++) + if (isCellSelected(row, col)) + results << QDateTime( + earliestDate.addDays(((double)qrand())= *((double)earliestDate.daysTo(latestDate))/((double)RAND_MAX)), + midnight.addMSecs(((qint64)qrand())*10= 00*60*60*24/RAND_MAX)); + else + results << col_ptr->dateTimeAt(row); + col_ptr->replaceDateTimes(first, results); + break; + } + } + + col_ptr->setSuppressDataChangedSignal(false); + col_ptr->setChanged(); + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::fillWithRandomValues() { - if (selectedColumnCount() < 1) return; - RandomValuesDialog* dlg =3D new RandomValuesDialog(m_spreadsheet); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->setColumns(selectedColumns()); - dlg->exec(); + if (selectedColumnCount() < 1) return; + RandomValuesDialog* dlg =3D new RandomValuesDialog(m_spreadsheet); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->setColumns(selectedColumns()); + dlg->exec(); } = void SpreadsheetView::fillWithEquidistantValues() { - if (selectedColumnCount() < 1) return; - EquidistantValuesDialog* dlg =3D new EquidistantValuesDialog(m_spreadshee= t); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->setColumns(selectedColumns()); - dlg->exec(); + if (selectedColumnCount() < 1) return; + EquidistantValuesDialog* dlg =3D new EquidistantValuesDialog(m_spreads= heet); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->setColumns(selectedColumns()); + dlg->exec(); } = void SpreadsheetView::fillWithFunctionValues() { - if (selectedColumnCount() < 1) return; - FunctionValuesDialog* dlg =3D new FunctionValuesDialog(m_spreadsheet); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->setColumns(selectedColumns()); - dlg->exec(); + if (selectedColumnCount() < 1) return; + FunctionValuesDialog* dlg =3D new FunctionValuesDialog(m_spreadsheet); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->setColumns(selectedColumns()); + dlg->exec(); } = void SpreadsheetView::fillSelectedCellsWithConstValues(){ - if (selectedColumnCount() < 1) return; - int first =3D firstSelectedRow(); - int last =3D lastSelectedRow(); - if ( first < 0 ) - return; - - bool doubleOk =3D false; - bool stringOk =3D false; - double doubleValue =3D 0; - QString stringValue; - - m_spreadsheet->beginMacro(i18n("%1: fill cells with const values", m_spre= adsheet->name())); - foreach(Column* col_ptr, selectedColumns()) { - int col =3D m_spreadsheet->indexOfChild(col_ptr); - col_ptr->setSuppressDataChangedSignal(true); - switch (col_ptr->columnMode()) { - case AbstractColumn::Numeric: { - if (!doubleOk) - doubleValue =3D QInputDialog::getDouble(this, i18n("Fill the selectio= n with constant value"), - i18n("Value"), 0, -2147483647, 2147483647, 6, &doubleOk); - if (doubleOk) { - WAIT_CURSOR; - QVector results(last-first+1); - for (int row=3Dfirst; row<=3Dlast; row++) { - if(isCellSelected(row, col)) - results[row-first] =3D doubleValue; - else - results[row-first] =3D col_ptr->valueAt(row); - } - col_ptr->replaceValues(first, results); - RESET_CURSOR; - } - break; - } - case AbstractColumn::Text: { - if (!stringOk) - stringValue =3D QInputDialog::getText(this, i18n("Fill the selection = with constant value"), - i18n("Value"), QLineEdit::Normal, 0, &stringOk); - if (stringOk && !stringValue.isEmpty()) { - WAIT_CURSOR; - QStringList results; - for (int row=3Dfirst; row<=3Dlast; row++) { - if (isCellSelected(row, col)) - results << stringValue; - else - results << col_ptr->textAt(row); - } - col_ptr->replaceTexts(first, results); - RESET_CURSOR; - } - break; - } - //TODO: handle other modes - default: - break; - } - - col_ptr->setSuppressDataChangedSignal(false); - col_ptr->setChanged(); - } - m_spreadsheet->endMacro(); + if (selectedColumnCount() < 1) return; + int first =3D firstSelectedRow(); + int last =3D lastSelectedRow(); + if ( first < 0 ) + return; + + bool doubleOk =3D false; + bool stringOk =3D false; + double doubleValue =3D 0; + QString stringValue; + + m_spreadsheet->beginMacro(i18n("%1: fill cells with const values", m_s= preadsheet->name())); + foreach(Column* col_ptr, selectedColumns()) { + int col =3D m_spreadsheet->indexOfChild(col_ptr); + col_ptr->setSuppressDataChangedSignal(true); + switch (col_ptr->columnMode()) { + case AbstractColumn::Numeric: { + if (!doubleOk) + doubleValue =3D QInputDialog::getDouble(this, i18n("Fi= ll the selection with constant value"), + i18n("Value"),= 0, -2147483647, 2147483647, 6, &doubleOk); + if (doubleOk) { + WAIT_CURSOR; + QVector results(last-first+1); + for (int row=3Dfirst; row<=3Dlast; row++) { + if(isCellSelected(row, col)) + results[row-first] =3D doubleValue; + else + results[row-first] =3D col_ptr->valueAt(row); + } + col_ptr->replaceValues(first, results); + RESET_CURSOR; + } + break; + } + case AbstractColumn::Text: { + if (!stringOk) + stringValue =3D QInputDialog::getText(this, i18n("Fill= the selection with constant value"), + i18n("Value"),= QLineEdit::Normal, 0, &stringOk); + if (stringOk && !stringValue.isEmpty()) { + WAIT_CURSOR; + QStringList results; + for (int row=3Dfirst; row<=3Dlast; row++) { + if (isCellSelected(row, col)) + results << stringValue; + else + results << col_ptr->textAt(row); + } + col_ptr->replaceTexts(first, results); + RESET_CURSOR; + } + break; + } + //TODO: handle other modes + default: + break; + } + + col_ptr->setSuppressDataChangedSignal(false); + col_ptr->setChanged(); + } + m_spreadsheet->endMacro(); } = /*! - Open the sort dialog for all columns. + Open the sort dialog for all columns. */ void SpreadsheetView::sortSpreadsheet(){ - sortDialog(m_spreadsheet->children()); + sortDialog(m_spreadsheet->children()); } = /*! Insert columns depending on the selection. */ void SpreadsheetView::insertEmptyColumns(){ - int first =3D firstSelectedColumn(); - if ( first < 0 ) return; - int last =3D lastSelectedColumn(); - int count, current =3D first; - - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: insert empty columns", m_spreadsheet-= >name())); - int rows =3D m_spreadsheet->rowCount(); - while( current <=3D last ) - { - current =3D first+1; - while( current <=3D last && isColumnSelected(current) ) current++; - count =3D current-first; - Column *first_col =3D m_spreadsheet->child(first); - for (int i=3D0; isetPlotDesignation(AbstractColumn::Y); - new_col->insertRows(0, rows); - m_spreadsheet->insertChildBefore(new_col, first_col); - } - current +=3D count; - last +=3D count; - while( current <=3D last && !isColumnSelected(current) ) current++; - first =3D current; - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + int first =3D firstSelectedColumn(); + if ( first < 0 ) return; + int last =3D lastSelectedColumn(); + int count, current =3D first; + + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: insert empty columns", m_spreadshe= et->name())); + int rows =3D m_spreadsheet->rowCount(); + while( current <=3D last ) + { + current =3D first+1; + while( current <=3D last && isColumnSelected(current) ) current++; + count =3D current-first; + Column *first_col =3D m_spreadsheet->child(first); + for (int i=3D0; isetPlotDesignation(AbstractColumn::Y); + new_col->insertRows(0, rows); + m_spreadsheet->insertChildBefore(new_col, first_col); + } + current +=3D count; + last +=3D count; + while( current <=3D last && !isColumnSelected(current) ) current++; + first =3D current; + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::removeSelectedColumns(){ - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: remove selected columns", m_spreadshe= et->name())); + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: remove selected columns", m_spread= sheet->name())); = - QList< Column* > list =3D selectedColumns(); - foreach(Column* ptr, list) - m_spreadsheet->removeChild(ptr); + QList< Column* > list =3D selectedColumns(); + foreach(Column* ptr, list) + m_spreadsheet->removeChild(ptr); = - m_spreadsheet->endMacro(); - RESET_CURSOR; + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::clearSelectedColumns(){ - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: clear selected columns", m_spreadshee= t->name())); - - QList< Column* > list =3D selectedColumns(); - if (formulaModeActive()) { - foreach(Column* ptr, list) { - ptr->setSuppressDataChangedSignal(true); - ptr->clearFormulas(); - ptr->setSuppressDataChangedSignal(false); - ptr->setChanged(); - } - }else{ - foreach(Column* ptr, list) { - ptr->setSuppressDataChangedSignal(true); - ptr->clear(); - ptr->setSuppressDataChangedSignal(false); - ptr->setChanged(); - } - } - - m_spreadsheet->endMacro(); - RESET_CURSOR; + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: clear selected columns", m_spreads= heet->name())); + + QList< Column* > list =3D selectedColumns(); + if (formulaModeActive()) { + foreach(Column* ptr, list) { + ptr->setSuppressDataChangedSignal(true); + ptr->clearFormulas(); + ptr->setSuppressDataChangedSignal(false); + ptr->setChanged(); + } + }else{ + foreach(Column* ptr, list) { + ptr->setSuppressDataChangedSignal(true); + ptr->clear(); + ptr->setSuppressDataChangedSignal(false); + ptr->setChanged(); + } + } + + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::setSelectionAs(AbstractColumn::PlotDesignation pd){ - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: set plot designation", m_spreadsheet-= >name())); + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: set plot designation", m_spreadshe= et->name())); = - QList< Column* > list =3D selectedColumns(); - foreach(Column* ptr, list) - ptr->setPlotDesignation(pd); + QList< Column* > list =3D selectedColumns(); + foreach(Column* ptr, list) + ptr->setPlotDesignation(pd); = - m_spreadsheet->endMacro(); - RESET_CURSOR; + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::setSelectedColumnsAsX(){ - setSelectionAs(AbstractColumn::X); + setSelectionAs(AbstractColumn::X); } = void SpreadsheetView::setSelectedColumnsAsY(){ - setSelectionAs(AbstractColumn::Y); + setSelectionAs(AbstractColumn::Y); } = void SpreadsheetView::setSelectedColumnsAsZ(){ - setSelectionAs(AbstractColumn::Z); + setSelectionAs(AbstractColumn::Z); } = void SpreadsheetView::setSelectedColumnsAsYError(){ - setSelectionAs(AbstractColumn::yErr); + setSelectionAs(AbstractColumn::yErr); } = void SpreadsheetView::setSelectedColumnsAsXError(){ - setSelectionAs(AbstractColumn::xErr); + setSelectionAs(AbstractColumn::xErr); } = void SpreadsheetView::setSelectedColumnsAsNone(){ - setSelectionAs(AbstractColumn::noDesignation); + setSelectionAs(AbstractColumn::noDesignation); } = void SpreadsheetView::normalizeSelectedColumns(){ - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: normalize columns", m_spreadsheet->na= me())); - QList< Column* > cols =3D selectedColumns(); - foreach(Column* col, cols) { - if (col->columnMode() =3D=3D AbstractColumn::Numeric) { - col->setSuppressDataChangedSignal(true); - double max =3D col->maximum(); - if (max !=3D 0.0) {// avoid division by zero - for (int row=3D0; rowrowCount(); row++) - col->setValueAt(row, col->valueAt(row) / max); - } - col->setSuppressDataChangedSignal(false); - col->setChanged(); - } - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: normalize columns", m_spreadsheet-= >name())); + QList< Column* > cols =3D selectedColumns(); + foreach(Column* col, cols) { + if (col->columnMode() =3D=3D AbstractColumn::Numeric) { + col->setSuppressDataChangedSignal(true); + double max =3D col->maximum(); + if (max !=3D 0.0) {// avoid division by zero + for (int row=3D0; rowrowCount(); row++) + col->setValueAt(row, col->valueAt(row) / max); + } + col->setSuppressDataChangedSignal(false); + col->setChanged(); + } + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::normalizeSelection(){ - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: normalize selection", m_spreadsheet->= name())); - double max =3D 0.0; - for (int col=3DfirstSelectedColumn(); col<=3DlastSelectedColumn(); col++) - if (m_spreadsheet->column(col)->columnMode() =3D=3D AbstractColumn::Nume= ric) - for (int row=3D0; rowrowCount(); row++) - { - if (isCellSelected(row, col) && m_spreadsheet->column(col)->valueAt(ro= w) > max) - max =3D m_spreadsheet->column(col)->valueAt(row); - } - - if (max !=3D 0.0) // avoid division by zero - { - //TODO setSuppressDataChangedSignal - for (int col=3DfirstSelectedColumn(); col<=3DlastSelectedColumn(); col++) - if (m_spreadsheet->column(col)->columnMode() =3D=3D AbstractColumn::Num= eric) - for (int row=3D0; rowrowCount(); row++) - { - if (isCellSelected(row, col)) - m_spreadsheet->column(col)->setValueAt(row, m_spreadsheet->column(co= l)->valueAt(row) / max); - } - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: normalize selection", m_spreadshee= t->name())); + double max =3D 0.0; + for (int col=3DfirstSelectedColumn(); col<=3DlastSelectedColumn(); col= ++) + if (m_spreadsheet->column(col)->columnMode() =3D=3D AbstractColumn= ::Numeric) + for (int row=3D0; rowrowCount(); row++) + { + if (isCellSelected(row, col) && m_spreadsheet->column(col)= ->valueAt(row) > max) + max =3D m_spreadsheet->column(col)->valueAt(row); + } + + if (max !=3D 0.0) // avoid division by zero + { + //TODO setSuppressDataChangedSignal + for (int col=3DfirstSelectedColumn(); col<=3DlastSelectedColumn();= col++) + if (m_spreadsheet->column(col)->columnMode() =3D=3D AbstractCo= lumn::Numeric) + for (int row=3D0; rowrowCount(); row++) + { + if (isCellSelected(row, col)) + m_spreadsheet->column(col)->setValueAt(row, m_spre= adsheet->column(col)->valueAt(row) / max); + } + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::sortSelectedColumns(){ - QList< Column* > cols =3D selectedColumns(); - sortDialog(cols); + QList< Column* > cols =3D selectedColumns(); + sortDialog(cols); } = = // TODO void SpreadsheetView::statisticsOnSelectedColumns(){ - QMessageBox::information(0, "info", "not yet implemented"); + QMessageBox::information(0, "info", "not yet implemented"); } = // TODO void SpreadsheetView::statisticsOnSelectedRows(){ - QMessageBox::information(0, "info", "not yet implemented"); + QMessageBox::information(0, "info", "not yet implemented"); } = /*! Insert rows depending on the selection. */ void SpreadsheetView::insertEmptyRows(){ - int first =3D firstSelectedRow(); - if ( first < 0 ) return; - int last =3D lastSelectedRow(); - int count, current =3D first; - - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: insert empty rows", m_spreadsheet->na= me())); - while( current <=3D last ){ - current =3D first+1; - while( current <=3D last && isRowSelected(current) ) current++; - count =3D current-first; - m_spreadsheet->insertRows(first, count); - current +=3D count; - last +=3D count; - while( current <=3D last && !isRowSelected(current) ) current++; - first =3D current; - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + int first =3D firstSelectedRow(); + if ( first < 0 ) return; + int last =3D lastSelectedRow(); + int count, current =3D first; + + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: insert empty rows", m_spreadsheet-= >name())); + while( current <=3D last ){ + current =3D first+1; + while( current <=3D last && isRowSelected(current) ) current++; + count =3D current-first; + m_spreadsheet->insertRows(first, count); + current +=3D count; + last +=3D count; + while( current <=3D last && !isRowSelected(current) ) current++; + first =3D current; + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::removeSelectedRows(){ - if ( firstSelectedRow() < 0 ) return; + if ( firstSelectedRow() < 0 ) return; = - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: remove selected rows", m_spreadsheet-= >name())); - //TODO setSuppressDataChangedSignal - foreach(const Interval& i, selectedRows().intervals()) - m_spreadsheet->removeRows(i.start(), i.size()); - m_spreadsheet->endMacro(); - RESET_CURSOR; + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: remove selected rows", m_spreadshe= et->name())); + //TODO setSuppressDataChangedSignal + foreach(const Interval& i, selectedRows().intervals()) + m_spreadsheet->removeRows(i.start(), i.size()); + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::clearSelectedRows(){ - if ( firstSelectedRow() < 0 ) return; - - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: clear selected rows", m_spreadsheet->= name())); - QList list =3D selectedColumns(); - foreach(Column* col_ptr, list) { - col_ptr->setSuppressDataChangedSignal(true); - if (formulaModeActive()) { - foreach(const Interval& i, selectedRows().intervals()) - col_ptr->setFormula(i, ""); - } else { - foreach(const Interval& i, selectedRows().intervals()) { - if (i.end() =3D=3D col_ptr->rowCount()-1) - col_ptr->removeRows(i.start(), i.size()); - else { - QStringList empties; - for (int j=3D0; jasStringColumn()->replaceTexts(i.start(), empties); - } - } - } - - col_ptr->setSuppressDataChangedSignal(false); - col_ptr->setChanged(); - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + if ( firstSelectedRow() < 0 ) return; + + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: clear selected rows", m_spreadshee= t->name())); + QList list =3D selectedColumns(); + foreach(Column* col_ptr, list) { + col_ptr->setSuppressDataChangedSignal(true); + if (formulaModeActive()) { + foreach(const Interval& i, selectedRows().intervals()) + col_ptr->setFormula(i, ""); + } else { + foreach(const Interval& i, selectedRows().intervals()) { + if (i.end() =3D=3D col_ptr->rowCount()-1) + col_ptr->removeRows(i.start(), i.size()); + else { + QStringList empties; + for (int j=3D0; jasStringColumn()->replaceTexts(i.start(), emp= ties); + } + } + } + + col_ptr->setSuppressDataChangedSignal(false); + col_ptr->setChanged(); + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::clearSelectedCells(){ - int first =3D firstSelectedRow(); - int last =3D lastSelectedRow(); - if ( first < 0 ) return; - - WAIT_CURSOR; - m_spreadsheet->beginMacro(i18n("%1: clear selected cells", m_spreadsheet-= >name())); - QList list =3D selectedColumns(); - foreach(Column* col_ptr, list) { - col_ptr->setSuppressDataChangedSignal(true); - if (formulaModeActive()) - { - int col =3D m_spreadsheet->indexOfChild(col_ptr); - for (int row=3Dlast; row>=3Dfirst; row--) - if (isCellSelected(row, col)) - { - col_ptr->setFormula(row, ""); - } - } - else - { - int col =3D m_spreadsheet->indexOfChild(col_ptr); - for (int row=3Dlast; row>=3Dfirst; row--) - if (isCellSelected(row, col)) - { - if (row < col_ptr->rowCount()) - col_ptr->asStringColumn()->setTextAt(row, QString()); - } - } - col_ptr->setSuppressDataChangedSignal(false); - col_ptr->setChanged(); - } - m_spreadsheet->endMacro(); - RESET_CURSOR; + int first =3D firstSelectedRow(); + int last =3D lastSelectedRow(); + if ( first < 0 ) return; + + WAIT_CURSOR; + m_spreadsheet->beginMacro(i18n("%1: clear selected cells", m_spreadshe= et->name())); + QList list =3D selectedColumns(); + foreach(Column* col_ptr, list) { + col_ptr->setSuppressDataChangedSignal(true); + if (formulaModeActive()) + { + int col =3D m_spreadsheet->indexOfChild(col_ptr); + for (int row=3Dlast; row>=3Dfirst; row--) + if (isCellSelected(row, col)) + { + col_ptr->setFormula(row, ""); + } + } + else + { + int col =3D m_spreadsheet->indexOfChild(col_ptr); + for (int row=3Dlast; row>=3Dfirst; row--) + if (isCellSelected(row, col)) + { + if (row < col_ptr->rowCount()) + col_ptr->asStringColumn()->setTextAt(row, QString(= )); + } + } + col_ptr->setSuppressDataChangedSignal(false); + col_ptr->setChanged(); + } + m_spreadsheet->endMacro(); + RESET_CURSOR; } = void SpreadsheetView::goToCell(){ - bool ok; + bool ok; = - int col =3D QInputDialog::getInteger(0, i18n("Go to Cell"), i18n("Enter c= olumn"), - 1, 1, m_spreadsheet->columnCount(), 1, &ok); - if ( !ok ) return; + int col =3D QInputDialog::getInteger(0, i18n("Go to Cell"), i18n("Ente= r column"), + 1, 1, m_spreadsheet->columnCount(), 1, &ok); + if ( !ok ) return; = - int row =3D QInputDialog::getInteger(0, i18n("Go to Cell"), i18n("Enter r= ow"), - 1, 1, m_spreadsheet->rowCount(), 1, &ok); - if ( !ok ) return; + int row =3D QInputDialog::getInteger(0, i18n("Go to Cell"), i18n("Ente= r row"), + 1, 1, m_spreadsheet->rowCount(), 1, &ok); + if ( !ok ) return; = - goToCell(row-1, col-1); + goToCell(row-1, col-1); } = //! Open the sort dialog for the given columns void SpreadsheetView::sortDialog(QList cols){ - if (cols.isEmpty()) return; + if (cols.isEmpty()) return; = - foreach(Column* col, cols) - col->setSuppressDataChangedSignal(true); + foreach(Column* col, cols) + col->setSuppressDataChangedSignal(true); = - SortDialog* dlg =3D new SortDialog(); - dlg->setAttribute(Qt::WA_DeleteOnClose); - connect(dlg, SIGNAL(sort(Column*,QList,bool)), m_spreadsheet, SL= OT(sortColumns(Column*,QList,bool))); - dlg->setColumnsList(cols); - int rc =3D dlg->exec(); + SortDialog* dlg =3D new SortDialog(); + dlg->setAttribute(Qt::WA_DeleteOnClose); + connect(dlg, SIGNAL(sort(Column*,QList,bool)), m_spreadsheet,= SLOT(sortColumns(Column*,QList,bool))); + dlg->setColumnsList(cols); + int rc =3D dlg->exec(); = - foreach(Column* col, cols) { - col->setSuppressDataChangedSignal(false); - if (rc=3D=3DQDialog::Accepted) - col->setChanged(); - } + foreach(Column* col, cols) { + col->setSuppressDataChangedSignal(false); + if (rc=3D=3DQDialog::Accepted) + col->setChanged(); + } } = void SpreadsheetView::sortColumnAscending(){ - QList< Column* > cols =3D selectedColumns(); - foreach(Column* col, cols) { - col->setSuppressDataChangedSignal(true); - } - m_spreadsheet->sortColumns(cols.first(), cols, true); - foreach(Column* col, cols) { - col->setSuppressDataChangedSignal(false); - col->setChanged(); - } + QList< Column* > cols =3D selectedColumns(); + foreach(Column* col, cols) { + col->setSuppressDataChangedSignal(true); + } + m_spreadsheet->sortColumns(cols.first(), cols, true); + foreach(Column* col, cols) { + col->setSuppressDataChangedSignal(false); + col->setChanged(); + } } = void SpreadsheetView::sortColumnDescending(){ - QList< Column* > cols =3D selectedColumns(); - foreach(Column* col, cols) { - col->setSuppressDataChangedSignal(true); - } - m_spreadsheet->sortColumns(cols.first(), cols, false); - foreach(Column* col, cols) { - col->setSuppressDataChangedSignal(false); - col->setChanged(); - } + QList< Column* > cols =3D selectedColumns(); + foreach(Column* col, cols) { + col->setSuppressDataChangedSignal(true); + } + m_spreadsheet->sortColumns(cols.first(), cols, false); + foreach(Column* col, cols) { + col->setSuppressDataChangedSignal(false); + col->setChanged(); + } } = /*! Append as many columns as are selected. */ void SpreadsheetView::addColumns(){ - m_spreadsheet->appendColumns(selectedColumnCount(false)); + m_spreadsheet->appendColumns(selectedColumnCount(false)); } = /*! Append as many rows as are selected. */ void SpreadsheetView::addRows(){ - m_spreadsheet->appendRows(selectedRowCount(false)); + m_spreadsheet->appendRows(selectedRowCount(false)); } = /*! Cause a repaint of the header. */ void SpreadsheetView::updateHeaderGeometry(Qt::Orientation o, int first, i= nt last){ - Q_UNUSED(first) - Q_UNUSED(last) - //TODO - if (o !=3D Qt::Horizontal) return; - m_tableView->horizontalHeader()->setStretchLastSection(true); // ugly ha= ck (flaw in Qt? Does anyone know a better way?) - m_tableView->horizontalHeader()->updateGeometry(); - m_tableView->horizontalHeader()->setStretchLastSection(false); // ugly ha= ck part 2 + Q_UNUSED(first) + Q_UNUSED(last) + //TODO + if (o !=3D Qt::Horizontal) return; + m_tableView->horizontalHeader()->setStretchLastSection(true); // ugly= hack (flaw in Qt? Does anyone know a better way?) + m_tableView->horizontalHeader()->updateGeometry(); + m_tableView->horizontalHeader()->setStretchLastSection(false); // ugly= hack part 2 } = void SpreadsheetView::keyPressEvent(QKeyEvent * event){ if (event->key() =3D=3D Qt::Key_Return || event->key() =3D=3D Qt::Key_= Enter) - advanceCell(); + advanceCell(); } = /*! @@ -1583,11 +1584,11 @@ void SpreadsheetView::columnClicked(int column){ Q_UNUSED(deselected); = if (m_suppressSelectionChangedEvent) - return; + return; = QItemSelectionModel* selModel =3D m_tableView->selectionModel(); for (int i=3D0; icolumnCount(); i++){ - m_spreadsheet->setColumnSelectedInView(i, selModel->isColumnSelected(i, Q= ModelIndex())); + m_spreadsheet->setColumnSelectedInView(i, selModel->isColumnSelected(i= , QModelIndex())); } } = @@ -1595,118 +1596,118 @@ void SpreadsheetView::columnClicked(int column){ prints the complete spreadsheet to \c printer. */ void SpreadsheetView::print(QPrinter* printer) const{ - QPainter painter (printer); - - int dpiy =3D printer->logicalDpiY(); - const int margin =3D (int) ( (1/2.54)*dpiy ); // 1 cm margins - - QHeaderView *hHeader =3D m_tableView->horizontalHeader(); - QHeaderView *vHeader =3D m_tableView->verticalHeader(); - - int rows =3D m_spreadsheet->rowCount(); - int cols =3D m_spreadsheet->columnCount(); - int height =3D margin; - int i; - int vertHeaderWidth =3D vHeader->width(); - int right =3D margin + vertHeaderWidth; - - //Paint the horizontal header first - painter.setFont(hHeader->font()); - QString headerString =3D m_tableView->model()->headerData(0, Qt::Horizont= al).toString(); - QRect br =3D painter.boundingRect(br, Qt::AlignCenter, headerString); - painter.drawLine(right, height, right, height+br.height()); - QRect tr(br); - - int w; - for (i=3D0; imodel()->headerData(i, Qt::Horizontal).toS= tring(); - w =3D m_tableView->columnWidth(i); - tr.setTopLeft(QPoint(right,height)); - tr.setWidth(w); - tr.setHeight(br.height()); - - painter.drawText(tr, Qt::AlignCenter, headerString); - right +=3D w; - painter.drawLine(right, height, right, height+tr.height()); - - if (right >=3D printer->pageRect().width()-2*margin ) - break; - } - - painter.drawLine(margin + vertHeaderWidth, height, right-1, height);//fir= st horizontal line - height +=3D tr.height(); - painter.drawLine(margin, height, right-1, height); - - - // print table values - QString cellText; - for (i=3D0; imodel()->headerData(i, Qt::Vertical).toString(= )+'\t'; - tr =3D painter.boundingRect(tr, Qt::AlignCenter, cellText); - painter.drawLine(right, height, right, height+tr.height()); - - br.setTopLeft(QPoint(right,height)); - br.setWidth(vertHeaderWidth); - br.setHeight(tr.height()); - painter.drawText(br, Qt::AlignCenter, cellText); - right +=3D vertHeaderWidth; - painter.drawLine(right, height, right, height+tr.height()); - - for(int j=3D0;jcolumnWidth(j); - cellText =3D m_spreadsheet->text(i,j)+'\t'; - tr =3D painter.boundingRect(tr,Qt::AlignCenter,cellText); - br.setTopLeft(QPoint(right,height)); - br.setWidth(w); - br.setHeight(tr.height()); - painter.drawText(br, Qt::AlignCenter, cellText); - right +=3D w; - painter.drawLine(right, height, right, height+tr.height()); - - if (right >=3D printer->width()-2*margin ) - break; - } - height +=3D br.height(); - painter.drawLine(margin, height, right-1, height); - - if (height >=3D printer->height()-margin ){ - printer->newPage(); - height =3D margin; - painter.drawLine(margin, height, right, height); - } - } + QPainter painter (printer); + + int dpiy =3D printer->logicalDpiY(); + const int margin =3D (int) ( (1/2.54)*dpiy ); // 1 cm margins + + QHeaderView *hHeader =3D m_tableView->horizontalHeader(); + QHeaderView *vHeader =3D m_tableView->verticalHeader(); + + int rows =3D m_spreadsheet->rowCount(); + int cols =3D m_spreadsheet->columnCount(); + int height =3D margin; + int i; + int vertHeaderWidth =3D vHeader->width(); + int right =3D margin + vertHeaderWidth; + + //Paint the horizontal header first + painter.setFont(hHeader->font()); + QString headerString =3D m_tableView->model()->headerData(0, Qt::Horiz= ontal).toString(); + QRect br =3D painter.boundingRect(br, Qt::AlignCenter, headerString); + painter.drawLine(right, height, right, height+br.height()); + QRect tr(br); + + int w; + for (i=3D0; imodel()->headerData(i, Qt::Horizonta= l).toString(); + w =3D m_tableView->columnWidth(i); + tr.setTopLeft(QPoint(right,height)); + tr.setWidth(w); + tr.setHeight(br.height()); + + painter.drawText(tr, Qt::AlignCenter, headerString); + right +=3D w; + painter.drawLine(right, height, right, height+tr.height()); + + if (right >=3D printer->pageRect().width()-2*margin ) + break; + } + + painter.drawLine(margin + vertHeaderWidth, height, right-1, height);//= first horizontal line + height +=3D tr.height(); + painter.drawLine(margin, height, right-1, height); + + + // print table values + QString cellText; + for (i=3D0; imodel()->headerData(i, Qt::Vertical).toS= tring()+'\t'; + tr =3D painter.boundingRect(tr, Qt::AlignCenter, cellText); + painter.drawLine(right, height, right, height+tr.height()); + + br.setTopLeft(QPoint(right,height)); + br.setWidth(vertHeaderWidth); + br.setHeight(tr.height()); + painter.drawText(br, Qt::AlignCenter, cellText); + right +=3D vertHeaderWidth; + painter.drawLine(right, height, right, height+tr.height()); + + for(int j=3D0;jcolumnWidth(j); + cellText =3D m_spreadsheet->text(i,j)+'\t'; + tr =3D painter.boundingRect(tr,Qt::AlignCenter,cellText); + br.setTopLeft(QPoint(right,height)); + br.setWidth(w); + br.setHeight(tr.height()); + painter.drawText(br, Qt::AlignCenter, cellText); + right +=3D w; + painter.drawLine(right, height, right, height+tr.height()); + + if (right >=3D printer->width()-2*margin ) + break; + } + height +=3D br.height(); + painter.drawLine(margin, height, right-1, height); + + if (height >=3D printer->height()-margin ){ + printer->newPage(); + height =3D margin; + painter.drawLine(margin, height, right, height); + } + } } = void SpreadsheetView::exportToFile(const QString& path, const bool exportH= eader, const QString& separator) const { - QFile file(path); - if (!file.open(QFile::WriteOnly | QFile::Truncate)) - return; - - QTextStream out(&file); - const int cols =3D m_spreadsheet->columnCount(); - - QString sep =3D separator; - sep =3D sep.replace(QString("TAB"), QString("\t"), Qt::CaseInsensitive); - sep =3D sep.replace(QString("SPACE"), QString(" "), Qt::CaseInsensitive); - - //export header (column names) - if (exportHeader) { - for (int j=3D0; jcolumn(j)->name(); - if (j!=3Dcols-1) - out<rowCount(); ++i) { - for (int j=3D0; jcolumn(j)->asStringColumn()->textAt(i); - if (j!=3Dcols-1) - out<columnCount(); + + QString sep =3D separator; + sep =3D sep.replace(QString("TAB"), QString("\t"), Qt::CaseInsensitive= ); + sep =3D sep.replace(QString("SPACE"), QString(" "), Qt::CaseInsensitiv= e); + + //export header (column names) + if (exportHeader) { + for (int j=3D0; jcolumn(j)->name(); + if (j!=3Dcols-1) + out<rowCount(); ++i) { + for (int j=3D0; jcolumn(j)->asStringColumn()->textAt(i); + if (j!=3Dcols-1) + out< #include = -#include +#include #include #include = @@ -64,345 +64,345 @@ Creates a view for the Worksheet \c worksheet and initializes the intern= al model. */ WorksheetView::WorksheetView(Worksheet* worksheet) : QGraphicsView(), - m_worksheet(worksheet), - m_mouseMode(SelectionMode), - m_cartesianPlotActionMode(ApplyActionToSelection), - m_cartesianPlotMouseMode(CartesianPlot::SelectionMode), - m_selectionBandIsShown(false), - m_suppressSelectionChangedEvent(false), - lastAddedWorksheetElement(0), - m_fadeInTimeLine(0), - m_fadeOutTimeLine(0), - tbNewCartesianPlot(0), - tbZoom(0) { - - setScene(m_worksheet->scene()); - - setRenderHint(QPainter::Antialiasing); - setRubberBandSelectionMode(Qt::ContainsItemBoundingRect); - setTransformationAnchor(QGraphicsView::AnchorUnderMouse); - setResizeAnchor(QGraphicsView::AnchorViewCenter); - setMinimumSize(16, 16); - setFocusPolicy(Qt::StrongFocus); - - if (m_worksheet->useViewSize()) { - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - } - - viewport()->setAttribute( Qt::WA_OpaquePaintEvent ); - viewport()->setAttribute( Qt::WA_NoSystemBackground ); + m_worksheet(worksheet), + m_mouseMode(SelectionMode), + m_cartesianPlotActionMode(ApplyActionToSelection), + m_cartesianPlotMouseMode(CartesianPlot::SelectionMode), + m_selectionBandIsShown(false), + m_suppressSelectionChangedEvent(false), + lastAddedWorksheetElement(0), + m_fadeInTimeLine(0), + m_fadeOutTimeLine(0), + tbNewCartesianPlot(0), + tbZoom(0) { + + setScene(m_worksheet->scene()); + + setRenderHint(QPainter::Antialiasing); + setRubberBandSelectionMode(Qt::ContainsItemBoundingRect); + setTransformationAnchor(QGraphicsView::AnchorUnderMouse); + setResizeAnchor(QGraphicsView::AnchorViewCenter); + setMinimumSize(16, 16); + setFocusPolicy(Qt::StrongFocus); + + if (m_worksheet->useViewSize()) { + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + } + + viewport()->setAttribute( Qt::WA_OpaquePaintEvent ); + viewport()->setAttribute( Qt::WA_NoSystemBackground ); // setAcceptDrops( true ); - setCacheMode(QGraphicsView::CacheBackground); - - m_gridSettings.style =3D WorksheetView::NoGrid; - - initActions(); - initMenus(); - selectionModeAction->setChecked(true); - handleCartesianPlotActions(); - - changeZoom(zoomOriginAction); - currentZoomAction=3DzoomInViewAction; - - //signal/slot connections - connect(m_worksheet, SIGNAL(requestProjectContextMenu(QMenu*)), this, SLO= T(createContextMenu(QMenu*))); - connect(m_worksheet, SIGNAL(itemSelected(QGraphicsItem*)), this, SLOT(sel= ectItem(QGraphicsItem*)) ); - connect(m_worksheet, SIGNAL(itemDeselected(QGraphicsItem*)), this, SLOT(d= eselectItem(QGraphicsItem*)) ); - connect(m_worksheet, SIGNAL(itemSelected(QGraphicsItem*)), this, SLOT(sel= ectItem(QGraphicsItem*)) ); - connect(m_worksheet, SIGNAL(itemDeselected(QGraphicsItem*)), this, SLOT(d= eselectItem(QGraphicsItem*)) ); - connect(m_worksheet, SIGNAL(requestUpdate()), this, SLOT(updateBackground= ()) ); - connect(m_worksheet, SIGNAL(aspectAboutToBeRemoved(const AbstractAspect*)= ), this, SLOT(aspectAboutToBeRemoved(const AbstractAspect*))); - connect(m_worksheet, SIGNAL(useViewSizeRequested()), this, SLOT(useViewSi= zeRequested()) ); - connect(m_worksheet, SIGNAL(layoutChanged(Worksheet::Layout)), this, SLOT= (layoutChanged(Worksheet::Layout)) ); - connect(scene(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged(= )) ); + setCacheMode(QGraphicsView::CacheBackground); + + m_gridSettings.style =3D WorksheetView::NoGrid; + + initActions(); + initMenus(); + selectionModeAction->setChecked(true); + handleCartesianPlotActions(); + + changeZoom(zoomOriginAction); + currentZoomAction=3DzoomInViewAction; + + //signal/slot connections + connect(m_worksheet, SIGNAL(requestProjectContextMenu(QMenu*)), this, = SLOT(createContextMenu(QMenu*))); + connect(m_worksheet, SIGNAL(itemSelected(QGraphicsItem*)), this, SLOT(= selectItem(QGraphicsItem*)) ); + connect(m_worksheet, SIGNAL(itemDeselected(QGraphicsItem*)), this, SLO= T(deselectItem(QGraphicsItem*)) ); + connect(m_worksheet, SIGNAL(itemSelected(QGraphicsItem*)), this, SLOT(= selectItem(QGraphicsItem*)) ); + connect(m_worksheet, SIGNAL(itemDeselected(QGraphicsItem*)), this, SLO= T(deselectItem(QGraphicsItem*)) ); + connect(m_worksheet, SIGNAL(requestUpdate()), this, SLOT(updateBackgro= und()) ); + connect(m_worksheet, SIGNAL(aspectAboutToBeRemoved(const AbstractAspec= t*)), this, SLOT(aspectAboutToBeRemoved(const AbstractAspect*))); + connect(m_worksheet, SIGNAL(useViewSizeRequested()), this, SLOT(useVie= wSizeRequested()) ); + connect(m_worksheet, SIGNAL(layoutChanged(Worksheet::Layout)), this, S= LOT(layoutChanged(Worksheet::Layout)) ); + connect(scene(), SIGNAL(selectionChanged()), this, SLOT(selectionChang= ed()) ); } = void WorksheetView::initActions(){ - QActionGroup* addNewActionGroup =3D new QActionGroup(this); - QActionGroup* zoomActionGroup =3D new QActionGroup(this); - QActionGroup* mouseModeActionGroup =3D new QActionGroup(this); - QActionGroup* layoutActionGroup =3D new QActionGroup(this); - QActionGroup* gridActionGroup =3D new QActionGroup(this); - gridActionGroup->setExclusive(true); - - selectAllAction =3D new KAction(KIcon("edit-select-all"), i18n("Select al= l"), this); - selectAllAction->setShortcut(Qt::CTRL+Qt::Key_A); - this->addAction(selectAllAction); - connect(selectAllAction, SIGNAL(triggered()), SLOT(selectAllElements())); - - deleteAction =3D new KAction(KIcon("edit-delete"), i18n("Delete"), this); - deleteAction->setShortcut(Qt::Key_Delete); - this->addAction(deleteAction); - connect(deleteAction, SIGNAL(triggered()), SLOT(deleteElement())); - - backspaceAction =3D new KAction(this); - backspaceAction->setShortcut(Qt::Key_Backspace); - this->addAction(backspaceAction); - connect(backspaceAction, SIGNAL(triggered()), SLOT(deleteElement())); - - //Zoom actions - zoomInViewAction =3D new KAction(KIcon("zoom-in"), i18n("Zoom in"), zoomA= ctionGroup); - zoomInViewAction->setShortcut(Qt::CTRL+Qt::Key_Plus); - - zoomOutViewAction =3D new KAction(KIcon("zoom-out"), i18n("Zoom out"), zo= omActionGroup); - zoomOutViewAction->setShortcut(Qt::CTRL+Qt::Key_Minus); - - zoomOriginAction =3D new KAction(KIcon("zoom-original"), i18n("Original s= ize"), zoomActionGroup); - zoomOriginAction->setShortcut(Qt::CTRL+Qt::Key_1); - - zoomFitPageHeightAction =3D new KAction(KIcon("zoom-fit-height"), i18n("F= it to height"), zoomActionGroup); - zoomFitPageWidthAction =3D new KAction(KIcon("zoom-fit-width"), i18n("Fit= to width"), zoomActionGroup); - zoomFitSelectionAction =3D new KAction(i18n("Fit to selection"), zoomActi= onGroup); - - // Mouse mode actions - selectionModeAction =3D new KAction(KIcon("cursor-arrow"), i18n("Select a= nd Edit"), mouseModeActionGroup); - selectionModeAction->setCheckable(true); - - navigationModeAction =3D new KAction(KIcon("input-mouse"), i18n("Navigate= "), mouseModeActionGroup); - navigationModeAction->setCheckable(true); - - zoomSelectionModeAction =3D new KAction(KIcon("page-zoom"), i18n("Select = and Zoom"), mouseModeActionGroup); - zoomSelectionModeAction->setCheckable(true); - - //TODO implement later "group selection action" where multiple objects ca= n be selected by drawing a rectangular -// selectionModeAction =3D new KAction(KIcon("select-rectangular"), i18n(= "Selection"), mouseModeActionGroup); + QActionGroup* addNewActionGroup =3D new QActionGroup(this); + QActionGroup* zoomActionGroup =3D new QActionGroup(this); + QActionGroup* mouseModeActionGroup =3D new QActionGroup(this); + QActionGroup* layoutActionGroup =3D new QActionGroup(this); + QActionGroup* gridActionGroup =3D new QActionGroup(this); + gridActionGroup->setExclusive(true); + + selectAllAction =3D new QAction(QIcon("edit-select-all"), i18n("Select= all"), this); + selectAllAction->setShortcut(Qt::CTRL+Qt::Key_A); + this->addAction(selectAllAction); + connect(selectAllAction, SIGNAL(triggered()), SLOT(selectAllElements()= )); + + deleteAction =3D new QAction(QIcon("edit-delete"), i18n("Delete"), thi= s); + deleteAction->setShortcut(Qt::Key_Delete); + this->addAction(deleteAction); + connect(deleteAction, SIGNAL(triggered()), SLOT(deleteElement())); + + backspaceAction =3D new QAction(this); + backspaceAction->setShortcut(Qt::Key_Backspace); + this->addAction(backspaceAction); + connect(backspaceAction, SIGNAL(triggered()), SLOT(deleteElement())); + + //Zoom actions + zoomInViewAction =3D new QAction(QIcon("zoom-in"), i18n("Zoom in"), zo= omActionGroup); + zoomInViewAction->setShortcut(Qt::CTRL+Qt::Key_Plus); + + zoomOutViewAction =3D new QAction(QIcon("zoom-out"), i18n("Zoom out"),= zoomActionGroup); + zoomOutViewAction->setShortcut(Qt::CTRL+Qt::Key_Minus); + + zoomOriginAction =3D new QAction(QIcon("zoom-original"), i18n("Origina= l size"), zoomActionGroup); + zoomOriginAction->setShortcut(Qt::CTRL+Qt::Key_1); + + zoomFitPageHeightAction =3D new QAction(QIcon("zoom-fit-height"), i18n= ("Fit to height"), zoomActionGroup); + zoomFitPageWidthAction =3D new QAction(QIcon("zoom-fit-width"), i18n("= Fit to width"), zoomActionGroup); + zoomFitSelectionAction =3D new QAction(i18n("Fit to selection"), zoomA= ctionGroup); + + // Mouse mode actions + selectionModeAction =3D new QAction(QIcon("cursor-arrow"), i18n("Selec= t and Edit"), mouseModeActionGroup); + selectionModeAction->setCheckable(true); + + navigationModeAction =3D new QAction(QIcon("input-mouse"), i18n("Navig= ate"), mouseModeActionGroup); + navigationModeAction->setCheckable(true); + + zoomSelectionModeAction =3D new QAction(QIcon("page-zoom"), i18n("Sele= ct and Zoom"), mouseModeActionGroup); + zoomSelectionModeAction->setCheckable(true); + + //TODO implement later "group selection action" where multiple objects= can be selected by drawing a rectangular +// selectionModeAction =3D new QAction(QIcon("select-rectangular"), i18n(= "Selection"), mouseModeActionGroup); // selectionModeAction->setCheckable(true); = - //"Add new" related actions - addCartesianPlot1Action =3D new KAction(KIcon("cartesian-plot-four-axes")= , i18n("box plot, four axes"), addNewActionGroup); - addCartesianPlot2Action =3D new KAction(KIcon("cartesian-plot-two-axes"),= i18n("box plot, two axes"), addNewActionGroup); - addCartesianPlot3Action =3D new KAction(KIcon("cartesian-plot-two-axes-ce= ntered"), i18n("two axes, centered"), addNewActionGroup); - addCartesianPlot4Action =3D new KAction(KIcon("cartesian-plot-two-axes-ce= ntered-origin"), i18n("two axes, crossing at origin"), addNewActionGroup); - addTextLabelAction =3D new KAction(KIcon("draw-text"), i18n("text label")= , addNewActionGroup); + //"Add new" related actions + addCartesianPlot1Action =3D new QAction(QIcon("cartesian-plot-four-axe= s"), i18n("box plot, four axes"), addNewActionGroup); + addCartesianPlot2Action =3D new QAction(QIcon("cartesian-plot-two-axes= "), i18n("box plot, two axes"), addNewActionGroup); + addCartesianPlot3Action =3D new QAction(QIcon("cartesian-plot-two-axes= -centered"), i18n("two axes, centered"), addNewActionGroup); + addCartesianPlot4Action =3D new QAction(QIcon("cartesian-plot-two-axes= -centered-origin"), i18n("two axes, crossing at origin"), addNewActionGroup= ); + addTextLabelAction =3D new QAction(QIcon("draw-text"), i18n("text labe= l"), addNewActionGroup); = - //Layout actions - verticalLayoutAction =3D new KAction(KIcon("editvlayout"), i18n("Vertical= layout"), layoutActionGroup); - verticalLayoutAction->setObjectName("verticalLayoutAction"); - verticalLayoutAction->setCheckable(true); + //Layout actions + verticalLayoutAction =3D new QAction(QIcon("editvlayout"), i18n("Verti= cal layout"), layoutActionGroup); + verticalLayoutAction->setObjectName("verticalLayoutAction"); + verticalLayoutAction->setCheckable(true); = - horizontalLayoutAction =3D new KAction(KIcon("edithlayout"), i18n("Horizo= ntal layout"), layoutActionGroup); - horizontalLayoutAction->setObjectName("horizontalLayoutAction"); - horizontalLayoutAction->setCheckable(true); + horizontalLayoutAction =3D new QAction(QIcon("edithlayout"), i18n("Hor= izontal layout"), layoutActionGroup); + horizontalLayoutAction->setObjectName("horizontalLayoutAction"); + horizontalLayoutAction->setCheckable(true); = - gridLayoutAction =3D new KAction(KIcon("editgrid"), i18n("Grid layout"), = layoutActionGroup); - gridLayoutAction->setObjectName("gridLayoutAction"); - gridLayoutAction->setCheckable(true); + gridLayoutAction =3D new QAction(QIcon("editgrid"), i18n("Grid layout"= ), layoutActionGroup); + gridLayoutAction->setObjectName("gridLayoutAction"); + gridLayoutAction->setCheckable(true); = - breakLayoutAction =3D new KAction(KIcon("editbreaklayout"), i18n("Break l= ayout"), layoutActionGroup); - breakLayoutAction->setObjectName("breakLayoutAction"); - breakLayoutAction->setEnabled(false); + breakLayoutAction =3D new QAction(QIcon("editbreaklayout"), i18n("Brea= k layout"), layoutActionGroup); + breakLayoutAction->setObjectName("breakLayoutAction"); + breakLayoutAction->setEnabled(false); = //Grid actions - noGridAction =3D new KAction(i18n("no grid"), gridActionGroup); - noGridAction->setObjectName("noGridAction"); - noGridAction->setCheckable(true); - noGridAction->setChecked(true); - noGridAction->setData(WorksheetView::NoGrid); - - denseLineGridAction =3D new KAction(i18n("dense line grid"), gridActionGr= oup); - denseLineGridAction->setObjectName("denseLineGridAction"); - denseLineGridAction->setCheckable(true); - - sparseLineGridAction =3D new KAction(i18n("sparse line grid"), gridAction= Group); - sparseLineGridAction->setObjectName("sparseLineGridAction"); - sparseLineGridAction->setCheckable(true); - - denseDotGridAction =3D new KAction(i18n("dense dot grid"), gridActionGrou= p); - denseDotGridAction->setObjectName("denseDotGridAction"); - denseDotGridAction->setCheckable(true); - - sparseDotGridAction =3D new KAction(i18n("sparse dot grid"), gridActionGr= oup); - sparseDotGridAction->setObjectName("sparseDotGridAction"); - sparseDotGridAction->setCheckable(true); - - customGridAction =3D new KAction(i18n("custom grid"), gridActionGroup); - customGridAction->setObjectName("customGridAction"); - customGridAction->setCheckable(true); - - snapToGridAction =3D new KAction(i18n("snap to grid"), this); - snapToGridAction->setCheckable(true); - - //check the action corresponding to the currently active layout in worksh= eet - this->layoutChanged(m_worksheet->layout()); - - connect(addNewActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(addNew= (QAction*))); - connect(mouseModeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(mou= seModeChanged(QAction*))); - connect(zoomActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeZo= om(QAction*))); - connect(layoutActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(change= Layout(QAction*))); - connect(gridActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeGr= id(QAction*))); - connect(snapToGridAction, SIGNAL(triggered()), this, SLOT(changeSnapToGri= d())); - - - //action for cartesian plots - QActionGroup* cartesianPlotActionModeActionGroup =3D new QActionGroup(thi= s); - cartesianPlotActionModeActionGroup->setExclusive(true); - cartesianPlotApplyToSelectionAction =3D new KAction(i18n("selected plots"= ), cartesianPlotActionModeActionGroup); - cartesianPlotApplyToSelectionAction->setCheckable(true); - cartesianPlotApplyToSelectionAction->setChecked(true); - cartesianPlotApplyToAllAction =3D new KAction(i18n("all plots"), cartesia= nPlotActionModeActionGroup); - cartesianPlotApplyToAllAction->setCheckable(true); - connect(cartesianPlotActionModeActionGroup, SIGNAL(triggered(QAction*)), = SLOT(cartesianPlotActionModeChanged(QAction*))); - - QActionGroup* cartesianPlotMouseModeActionGroup =3D new QActionGroup(this= ); - cartesianPlotMouseModeActionGroup->setExclusive(true); - cartesianPlotSelectionModeAction =3D new KAction(KIcon("cursor-arrow"), i= 18n("Select and edit"), cartesianPlotMouseModeActionGroup); - cartesianPlotSelectionModeAction->setCheckable(true); - cartesianPlotSelectionModeAction->setChecked(true); - - cartesianPlotZoomSelectionModeAction =3D new KAction(KIcon("zoom-select")= , i18n("Select region and zoom in"), cartesianPlotMouseModeActionGroup); - cartesianPlotZoomSelectionModeAction->setCheckable(true); - - cartesianPlotZoomXSelectionModeAction =3D new KAction(KIcon("zoom-select-= x"), i18n("Select x-region and zoom in"), cartesianPlotMouseModeActionGroup= ); - cartesianPlotZoomXSelectionModeAction->setCheckable(true); - - cartesianPlotZoomYSelectionModeAction =3D new KAction(KIcon("zoom-select-= y"), i18n("Select y-region and zoom in"), cartesianPlotMouseModeActionGroup= ); - cartesianPlotZoomYSelectionModeAction->setCheckable(true); - - connect(cartesianPlotMouseModeActionGroup, SIGNAL(triggered(QAction*)), S= LOT(cartesianPlotMouseModeChanged(QAction*))); - - addCurveAction =3D new KAction(KIcon("xy-curve"), i18n("xy-curve"), this); - addEquationCurveAction =3D new KAction(KIcon("xy-equation-curve"), i18n("= xy-curve from a mathematical equation"), this); - addFitCurveAction =3D new KAction(KIcon("xy-fit-curve"), i18n("xy-curve f= rom a fit to data"), this); - addLegendAction =3D new KAction(KIcon("text-field"), i18n("legend"), this= ); - addHorizontalAxisAction =3D new KAction(KIcon("axis-horizontal"), i18n("h= orizontal axis"), this); - addVerticalAxisAction =3D new KAction(KIcon("axis-vertical"), i18n("verti= cal axis"), this); - - scaleAutoAction =3D new KAction(KIcon("auto-scale-all"), i18n("auto scale= "), this); - scaleAutoXAction =3D new KAction(KIcon("auto-scale-x"), i18n("auto scale = X"), this); - scaleAutoYAction =3D new KAction(KIcon("auto-scale-y"), i18n("auto scale = Y"), this); - zoomInAction =3D new KAction(KIcon("zoom-in"), i18n("zoom in"), this); - zoomOutAction =3D new KAction(KIcon("zoom-out"), i18n("zoom out"), this); - zoomInXAction =3D new KAction(KIcon("zoom-in-x"), i18n("zoom in X"), this= ); - zoomOutXAction =3D new KAction(KIcon("zoom-out-x"), i18n("zoom out X"), t= his); - zoomInYAction =3D new KAction(KIcon("zoom-in-y"), i18n("zoom in Y"), this= ); - zoomOutYAction =3D new KAction(KIcon("zoom-out-y"), i18n("zoom out Y"), t= his); - shiftLeftXAction =3D new KAction(KIcon("shift-left-x"), i18n("shift le= ft X"), this); - shiftRightXAction =3D new KAction(KIcon("shift-right-x"), i18n("shift rig= ht X"), this); - shiftUpYAction =3D new KAction(KIcon("shift-up-y"), i18n("shift up Y"), t= his); - shiftDownYAction =3D new KAction(KIcon("shift-down-y"), i18n("shift down = Y"), this); - - connect(addCurveAction, SIGNAL(triggered()), SLOT(addCurve())); - connect(addEquationCurveAction, SIGNAL(triggered()), SLOT(addEquationCurv= e())); - connect(addFitCurveAction, SIGNAL(triggered()), SLOT(addFitCurve())); - connect(addLegendAction, SIGNAL(triggered()), SLOT(addLegend())); - connect(addHorizontalAxisAction, SIGNAL(triggered()), SLOT(addHorizontalA= xis())); - connect(addVerticalAxisAction, SIGNAL(triggered()), SLOT(addVerticalAxis(= ))); - - //zoom actions - connect(scaleAutoAction, SIGNAL(triggered()), SLOT(scaleAuto())); - connect(scaleAutoXAction, SIGNAL(triggered()), SLOT(scaleAutoX())); - connect(scaleAutoYAction, SIGNAL(triggered()), SLOT(scaleAutoY())); - connect(zoomInAction, SIGNAL(triggered()), SLOT(zoomIn())); - connect(zoomOutAction, SIGNAL(triggered()), SLOT(zoomOut())); - connect(zoomInXAction, SIGNAL(triggered()), SLOT(zoomInX())); - connect(zoomOutXAction, SIGNAL(triggered()), SLOT(zoomOutX())); - connect(zoomInYAction, SIGNAL(triggered()), SLOT(zoomInY())); - connect(zoomOutYAction, SIGNAL(triggered()), SLOT(zoomOutY())); - connect(shiftLeftXAction, SIGNAL(triggered()), SLOT(shiftLeftX())); - connect(shiftRightXAction, SIGNAL(triggered()), SLOT(shiftRightX())); - connect(shiftUpYAction, SIGNAL(triggered()), SLOT(shiftUpY())); - connect(shiftDownYAction, SIGNAL(triggered()), SLOT(shiftDownY())); + noGridAction =3D new QAction(i18n("no grid"), gridActionGroup); + noGridAction->setObjectName("noGridAction"); + noGridAction->setCheckable(true); + noGridAction->setChecked(true); + noGridAction->setData(WorksheetView::NoGrid); + + denseLineGridAction =3D new QAction(i18n("dense line grid"), gridActio= nGroup); + denseLineGridAction->setObjectName("denseLineGridAction"); + denseLineGridAction->setCheckable(true); + + sparseLineGridAction =3D new QAction(i18n("sparse line grid"), gridAct= ionGroup); + sparseLineGridAction->setObjectName("sparseLineGridAction"); + sparseLineGridAction->setCheckable(true); + + denseDotGridAction =3D new QAction(i18n("dense dot grid"), gridActionG= roup); + denseDotGridAction->setObjectName("denseDotGridAction"); + denseDotGridAction->setCheckable(true); + + sparseDotGridAction =3D new QAction(i18n("sparse dot grid"), gridActio= nGroup); + sparseDotGridAction->setObjectName("sparseDotGridAction"); + sparseDotGridAction->setCheckable(true); + + customGridAction =3D new QAction(i18n("custom grid"), gridActionGroup); + customGridAction->setObjectName("customGridAction"); + customGridAction->setCheckable(true); + + snapToGridAction =3D new QAction(i18n("snap to grid"), this); + snapToGridAction->setCheckable(true); + + //check the action corresponding to the currently active layout in wor= ksheet + this->layoutChanged(m_worksheet->layout()); + + connect(addNewActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(add= New(QAction*))); + connect(mouseModeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(= mouseModeChanged(QAction*))); + connect(zoomActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(chang= eZoom(QAction*))); + connect(layoutActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(cha= ngeLayout(QAction*))); + connect(gridActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(chang= eGrid(QAction*))); + connect(snapToGridAction, SIGNAL(triggered()), this, SLOT(changeSnapTo= Grid())); + + + //action for cartesian plots + QActionGroup* cartesianPlotActionModeActionGroup =3D new QActionGroup(= this); + cartesianPlotActionModeActionGroup->setExclusive(true); + cartesianPlotApplyToSelectionAction =3D new QAction(i18n("selected plo= ts"), cartesianPlotActionModeActionGroup); + cartesianPlotApplyToSelectionAction->setCheckable(true); + cartesianPlotApplyToSelectionAction->setChecked(true); + cartesianPlotApplyToAllAction =3D new QAction(i18n("all plots"), carte= sianPlotActionModeActionGroup); + cartesianPlotApplyToAllAction->setCheckable(true); + connect(cartesianPlotActionModeActionGroup, SIGNAL(triggered(QAction*)= ), SLOT(cartesianPlotActionModeChanged(QAction*))); + + QActionGroup* cartesianPlotMouseModeActionGroup =3D new QActionGroup(t= his); + cartesianPlotMouseModeActionGroup->setExclusive(true); + cartesianPlotSelectionModeAction =3D new QAction(QIcon("cursor-arrow")= , i18n("Select and edit"), cartesianPlotMouseModeActionGroup); + cartesianPlotSelectionModeAction->setCheckable(true); + cartesianPlotSelectionModeAction->setChecked(true); + + cartesianPlotZoomSelectionModeAction =3D new QAction(QIcon("zoom-selec= t"), i18n("Select region and zoom in"), cartesianPlotMouseModeActionGroup); + cartesianPlotZoomSelectionModeAction->setCheckable(true); + + cartesianPlotZoomXSelectionModeAction =3D new QAction(QIcon("zoom-sele= ct-x"), i18n("Select x-region and zoom in"), cartesianPlotMouseModeActionGr= oup); + cartesianPlotZoomXSelectionModeAction->setCheckable(true); + + cartesianPlotZoomYSelectionModeAction =3D new QAction(QIcon("zoom-sele= ct-y"), i18n("Select y-region and zoom in"), cartesianPlotMouseModeActionGr= oup); + cartesianPlotZoomYSelectionModeAction->setCheckable(true); + + connect(cartesianPlotMouseModeActionGroup, SIGNAL(triggered(QAction*))= , SLOT(cartesianPlotMouseModeChanged(QAction*))); + + addCurveAction =3D new QAction(QIcon("xy-curve"), i18n("xy-curve"), th= is); + addEquationCurveAction =3D new QAction(QIcon("xy-equation-curve"), i18= n("xy-curve from a mathematical equation"), this); + addFitCurveAction =3D new QAction(QIcon("xy-fit-curve"), i18n("xy-curv= e from a fit to data"), this); + addLegendAction =3D new QAction(QIcon("text-field"), i18n("legend"), t= his); + addHorizontalAxisAction =3D new QAction(QIcon("axis-horizontal"), i18n= ("horizontal axis"), this); + addVerticalAxisAction =3D new QAction(QIcon("axis-vertical"), i18n("ve= rtical axis"), this); + + scaleAutoAction =3D new QAction(QIcon("auto-scale-all"), i18n("auto sc= ale"), this); + scaleAutoXAction =3D new QAction(QIcon("auto-scale-x"), i18n("auto sca= le X"), this); + scaleAutoYAction =3D new QAction(QIcon("auto-scale-y"), i18n("auto sca= le Y"), this); + zoomInAction =3D new QAction(QIcon("zoom-in"), i18n("zoom in"), this); + zoomOutAction =3D new QAction(QIcon("zoom-out"), i18n("zoom out"), thi= s); + zoomInXAction =3D new QAction(QIcon("zoom-in-x"), i18n("zoom in X"), t= his); + zoomOutXAction =3D new QAction(QIcon("zoom-out-x"), i18n("zoom out X")= , this); + zoomInYAction =3D new QAction(QIcon("zoom-in-y"), i18n("zoom in Y"), t= his); + zoomOutYAction =3D new QAction(QIcon("zoom-out-y"), i18n("zoom out Y")= , this); + shiftLeftXAction =3D new QAction(QIcon("shift-left-x"), i18n("shift le= ft X"), this); + shiftRightXAction =3D new QAction(QIcon("shift-right-x"), i18n("shift = right X"), this); + shiftUpYAction =3D new QAction(QIcon("shift-up-y"), i18n("shift up Y")= , this); + shiftDownYAction =3D new QAction(QIcon("shift-down-y"), i18n("shift do= wn Y"), this); + + connect(addCurveAction, SIGNAL(triggered()), SLOT(addCurve())); + connect(addEquationCurveAction, SIGNAL(triggered()), SLOT(addEquationC= urve())); + connect(addFitCurveAction, SIGNAL(triggered()), SLOT(addFitCurve())); + connect(addLegendAction, SIGNAL(triggered()), SLOT(addLegend())); + connect(addHorizontalAxisAction, SIGNAL(triggered()), SLOT(addHorizont= alAxis())); + connect(addVerticalAxisAction, SIGNAL(triggered()), SLOT(addVerticalAx= is())); + + //zoom actions + connect(scaleAutoAction, SIGNAL(triggered()), SLOT(scaleAuto())); + connect(scaleAutoXAction, SIGNAL(triggered()), SLOT(scaleAutoX())); + connect(scaleAutoYAction, SIGNAL(triggered()), SLOT(scaleAutoY())); + connect(zoomInAction, SIGNAL(triggered()), SLOT(zoomIn())); + connect(zoomOutAction, SIGNAL(triggered()), SLOT(zoomOut())); + connect(zoomInXAction, SIGNAL(triggered()), SLOT(zoomInX())); + connect(zoomOutXAction, SIGNAL(triggered()), SLOT(zoomOutX())); + connect(zoomInYAction, SIGNAL(triggered()), SLOT(zoomInY())); + connect(zoomOutYAction, SIGNAL(triggered()), SLOT(zoomOutY())); + connect(shiftLeftXAction, SIGNAL(triggered()), SLOT(shiftLeftX())); + connect(shiftRightXAction, SIGNAL(triggered()), SLOT(shiftRightX())); + connect(shiftUpYAction, SIGNAL(triggered()), SLOT(shiftUpY())); + connect(shiftDownYAction, SIGNAL(triggered()), SLOT(shiftDownY())); } = void WorksheetView::initMenus(){ - m_addNewCartesianPlotMenu =3D new QMenu(i18n("xy-plot")); - m_addNewCartesianPlotMenu->addAction(addCartesianPlot1Action); - m_addNewCartesianPlotMenu->addAction(addCartesianPlot2Action); - m_addNewCartesianPlotMenu->addAction(addCartesianPlot3Action); - m_addNewCartesianPlotMenu->addAction(addCartesianPlot4Action); - - m_addNewMenu =3D new QMenu(i18n("Add new")); - m_addNewMenu->addMenu(m_addNewCartesianPlotMenu)->setIcon(KIcon("office-c= hart-line")); - m_addNewMenu->addSeparator(); - m_addNewMenu->addAction(addTextLabelAction); - - m_viewMouseModeMenu =3D new QMenu(i18n("Mouse Mode")); - m_viewMouseModeMenu->setIcon(KIcon("input-mouse")); - m_viewMouseModeMenu->addAction(selectionModeAction); - m_viewMouseModeMenu->addAction(navigationModeAction); - m_viewMouseModeMenu->addAction(zoomSelectionModeAction); - - m_zoomMenu =3D new QMenu(i18n("Zoom")); - m_zoomMenu->setIcon(KIcon("zoom-draw")); - m_zoomMenu->addAction(zoomInViewAction); - m_zoomMenu->addAction(zoomOutViewAction); - m_zoomMenu->addAction(zoomOriginAction); - m_zoomMenu->addAction(zoomFitPageHeightAction); - m_zoomMenu->addAction(zoomFitPageWidthAction); - m_zoomMenu->addAction(zoomFitSelectionAction); - - m_layoutMenu =3D new QMenu(i18n("Layout")); - m_layoutMenu->addAction(verticalLayoutAction); - m_layoutMenu->addAction(horizontalLayoutAction); - m_layoutMenu->addAction(gridLayoutAction); - m_layoutMenu->addSeparator(); - m_layoutMenu->addAction(breakLayoutAction); - - m_gridMenu =3D new QMenu(i18n("Grid")); - m_gridMenu->setIcon(KIcon("view-grid")); - m_gridMenu->addAction(noGridAction); - m_gridMenu->addSeparator(); - m_gridMenu->addAction(sparseLineGridAction); - m_gridMenu->addAction(denseLineGridAction); - m_gridMenu->addSeparator(); - m_gridMenu->addAction(sparseDotGridAction); - m_gridMenu->addAction(denseDotGridAction); - m_gridMenu->addSeparator(); - m_gridMenu->addAction(customGridAction); - //TODO: implement "snap to grid" and activate this action + m_addNewCartesianPlotMenu =3D new QMenu(i18n("xy-plot")); + m_addNewCartesianPlotMenu->addAction(addCartesianPlot1Action); + m_addNewCartesianPlotMenu->addAction(addCartesianPlot2Action); + m_addNewCartesianPlotMenu->addAction(addCartesianPlot3Action); + m_addNewCartesianPlotMenu->addAction(addCartesianPlot4Action); + + m_addNewMenu =3D new QMenu(i18n("Add new")); + m_addNewMenu->addMenu(m_addNewCartesianPlotMenu)->setIcon(QIcon("offic= e-chart-line")); + m_addNewMenu->addSeparator(); + m_addNewMenu->addAction(addTextLabelAction); + + m_viewMouseModeMenu =3D new QMenu(i18n("Mouse Mode")); + m_viewMouseModeMenu->setIcon(QIcon("input-mouse")); + m_viewMouseModeMenu->addAction(selectionModeAction); + m_viewMouseModeMenu->addAction(navigationModeAction); + m_viewMouseModeMenu->addAction(zoomSelectionModeAction); + + m_zoomMenu =3D new QMenu(i18n("Zoom")); + m_zoomMenu->setIcon(QIcon("zoom-draw")); + m_zoomMenu->addAction(zoomInViewAction); + m_zoomMenu->addAction(zoomOutViewAction); + m_zoomMenu->addAction(zoomOriginAction); + m_zoomMenu->addAction(zoomFitPageHeightAction); + m_zoomMenu->addAction(zoomFitPageWidthAction); + m_zoomMenu->addAction(zoomFitSelectionAction); + + m_layoutMenu =3D new QMenu(i18n("Layout")); + m_layoutMenu->addAction(verticalLayoutAction); + m_layoutMenu->addAction(horizontalLayoutAction); + m_layoutMenu->addAction(gridLayoutAction); + m_layoutMenu->addSeparator(); + m_layoutMenu->addAction(breakLayoutAction); + + m_gridMenu =3D new QMenu(i18n("Grid")); + m_gridMenu->setIcon(QIcon("view-grid")); + m_gridMenu->addAction(noGridAction); + m_gridMenu->addSeparator(); + m_gridMenu->addAction(sparseLineGridAction); + m_gridMenu->addAction(denseLineGridAction); + m_gridMenu->addSeparator(); + m_gridMenu->addAction(sparseDotGridAction); + m_gridMenu->addAction(denseDotGridAction); + m_gridMenu->addSeparator(); + m_gridMenu->addAction(customGridAction); + //TODO: implement "snap to grid" and activate this action // m_gridMenu->addSeparator(); // m_gridMenu->addAction(snapToGridAction); = - m_cartesianPlotMenu =3D new QMenu(i18n("Cartesian Plot")); - - m_cartesianPlotMouseModeMenu =3D new QMenu(i18n("Mouse Mode")); - m_cartesianPlotMouseModeMenu->setIcon(KIcon("input-mouse")); - m_cartesianPlotMouseModeMenu->addAction(cartesianPlotSelectionModeAction); - m_cartesianPlotMouseModeMenu->addAction(cartesianPlotZoomSelectionModeAct= ion); - m_cartesianPlotMouseModeMenu->addAction(cartesianPlotZoomXSelectionModeAc= tion); - m_cartesianPlotMouseModeMenu->addAction(cartesianPlotZoomYSelectionModeAc= tion); - m_cartesianPlotMouseModeMenu->addSeparator(); - - m_cartesianPlotAddNewMenu =3D new QMenu(i18n("Add new")); - m_cartesianPlotAddNewMenu->addAction(addCurveAction); - m_cartesianPlotAddNewMenu->addAction(addEquationCurveAction); - m_cartesianPlotAddNewMenu->addAction(addFitCurveAction); - m_cartesianPlotAddNewMenu->addAction(addLegendAction); - m_cartesianPlotAddNewMenu->addSeparator(); - m_cartesianPlotAddNewMenu->addAction(addHorizontalAxisAction); - m_cartesianPlotAddNewMenu->addAction(addVerticalAxisAction); - - m_cartesianPlotZoomMenu =3D new QMenu(i18n("Zoom/Navigate")); - m_cartesianPlotZoomMenu->setIcon(KIcon("zoom-draw")); - m_cartesianPlotZoomMenu->addAction(scaleAutoAction); - m_cartesianPlotZoomMenu->addAction(scaleAutoXAction); - m_cartesianPlotZoomMenu->addAction(scaleAutoYAction); - m_cartesianPlotZoomMenu->addSeparator(); - m_cartesianPlotZoomMenu->addAction(zoomInAction); - m_cartesianPlotZoomMenu->addAction(zoomOutAction); - m_cartesianPlotZoomMenu->addSeparator(); - m_cartesianPlotZoomMenu->addAction(zoomInXAction); - m_cartesianPlotZoomMenu->addAction(zoomOutXAction); - m_cartesianPlotZoomMenu->addSeparator(); - m_cartesianPlotZoomMenu->addAction(zoomInYAction); - m_cartesianPlotZoomMenu->addAction(zoomOutYAction); - m_cartesianPlotZoomMenu->addSeparator(); - m_cartesianPlotZoomMenu->addAction(shiftLeftXAction); - m_cartesianPlotZoomMenu->addAction(shiftRightXAction); - m_cartesianPlotZoomMenu->addSeparator(); - m_cartesianPlotZoomMenu->addAction(shiftUpYAction); - m_cartesianPlotZoomMenu->addAction(shiftDownYAction); - - m_cartesianPlotActionModeMenu =3D new QMenu(i18n("Apply actions to")); - m_cartesianPlotActionModeMenu->addAction(cartesianPlotApplyToSelectionAct= ion); - m_cartesianPlotActionModeMenu->addAction(cartesianPlotApplyToAllAction); - - m_cartesianPlotMenu->addMenu(m_cartesianPlotMouseModeMenu); - m_cartesianPlotMenu->addMenu(m_cartesianPlotAddNewMenu); - m_cartesianPlotMenu->addMenu(m_cartesianPlotZoomMenu); - m_cartesianPlotMenu->addSeparator(); - m_cartesianPlotMenu->addMenu(m_cartesianPlotActionModeMenu); + m_cartesianPlotMenu =3D new QMenu(i18n("Cartesian Plot")); + + m_cartesianPlotMouseModeMenu =3D new QMenu(i18n("Mouse Mode")); + m_cartesianPlotMouseModeMenu->setIcon(QIcon("input-mouse")); + m_cartesianPlotMouseModeMenu->addAction(cartesianPlotSelectionModeActi= on); + m_cartesianPlotMouseModeMenu->addAction(cartesianPlotZoomSelectionMode= Action); + m_cartesianPlotMouseModeMenu->addAction(cartesianPlotZoomXSelectionMod= eAction); + m_cartesianPlotMouseModeMenu->addAction(cartesianPlotZoomYSelectionMod= eAction); + m_cartesianPlotMouseModeMenu->addSeparator(); + + m_cartesianPlotAddNewMenu =3D new QMenu(i18n("Add new")); + m_cartesianPlotAddNewMenu->addAction(addCurveAction); + m_cartesianPlotAddNewMenu->addAction(addEquationCurveAction); + m_cartesianPlotAddNewMenu->addAction(addFitCurveAction); + m_cartesianPlotAddNewMenu->addAction(addLegendAction); + m_cartesianPlotAddNewMenu->addSeparator(); + m_cartesianPlotAddNewMenu->addAction(addHorizontalAxisAction); + m_cartesianPlotAddNewMenu->addAction(addVerticalAxisAction); + + m_cartesianPlotZoomMenu =3D new QMenu(i18n("Zoom/Navigate")); + m_cartesianPlotZoomMenu->setIcon(QIcon("zoom-draw")); + m_cartesianPlotZoomMenu->addAction(scaleAutoAction); + m_cartesianPlotZoomMenu->addAction(scaleAutoXAction); + m_cartesianPlotZoomMenu->addAction(scaleAutoYAction); + m_cartesianPlotZoomMenu->addSeparator(); + m_cartesianPlotZoomMenu->addAction(zoomInAction); + m_cartesianPlotZoomMenu->addAction(zoomOutAction); + m_cartesianPlotZoomMenu->addSeparator(); + m_cartesianPlotZoomMenu->addAction(zoomInXAction); + m_cartesianPlotZoomMenu->addAction(zoomOutXAction); + m_cartesianPlotZoomMenu->addSeparator(); + m_cartesianPlotZoomMenu->addAction(zoomInYAction); + m_cartesianPlotZoomMenu->addAction(zoomOutYAction); + m_cartesianPlotZoomMenu->addSeparator(); + m_cartesianPlotZoomMenu->addAction(shiftLeftXAction); + m_cartesianPlotZoomMenu->addAction(shiftRightXAction); + m_cartesianPlotZoomMenu->addSeparator(); + m_cartesianPlotZoomMenu->addAction(shiftUpYAction); + m_cartesianPlotZoomMenu->addAction(shiftDownYAction); + + m_cartesianPlotActionModeMenu =3D new QMenu(i18n("Apply actions to")); + m_cartesianPlotActionModeMenu->addAction(cartesianPlotApplyToSelection= Action); + m_cartesianPlotActionModeMenu->addAction(cartesianPlotApplyToAllAction= ); + + m_cartesianPlotMenu->addMenu(m_cartesianPlotMouseModeMenu); + m_cartesianPlotMenu->addMenu(m_cartesianPlotAddNewMenu); + m_cartesianPlotMenu->addMenu(m_cartesianPlotZoomMenu); + m_cartesianPlotMenu->addSeparator(); + m_cartesianPlotMenu->addMenu(m_cartesianPlotActionModeMenu); } = /*! @@ -413,83 +413,83 @@ void WorksheetView::initMenus(){ * - as a part of the worksheet context menu in project explorer */ void WorksheetView::createContextMenu(QMenu* menu) const { - Q_ASSERT(menu); + Q_ASSERT(menu); = #ifdef ACTIVATE_SCIDAVIS_SPECIFIC_CODE - QAction* firstAction =3D menu->actions().first(); + QAction* firstAction =3D menu->actions().first(); #else - QAction* firstAction =3D 0; - // if we're populating the context menu for the project explorer, then - //there're already actions available there. Skip the first title-action - //and insert the action at the beginning of the menu. - if (menu->actions().size()>1) - firstAction =3D menu->actions().at(1); + QAction* firstAction =3D 0; + // if we're populating the context menu for the project explorer, then + //there're already actions available there. Skip the first title-action + //and insert the action at the beginning of the menu. + if (menu->actions().size()>1) + firstAction =3D menu->actions().at(1); #endif = - menu->insertMenu(firstAction, m_addNewMenu); - menu->insertSeparator(firstAction); - menu->insertMenu(firstAction, m_viewMouseModeMenu); - menu->insertMenu(firstAction, m_zoomMenu); - menu->insertMenu(firstAction, m_layoutMenu); - menu->insertMenu(firstAction, m_gridMenu); - menu->insertSeparator(firstAction); - menu->insertMenu(firstAction, m_cartesianPlotMenu); - menu->insertSeparator(firstAction); + menu->insertMenu(firstAction, m_addNewMenu); + menu->insertSeparator(firstAction); + menu->insertMenu(firstAction, m_viewMouseModeMenu); + menu->insertMenu(firstAction, m_zoomMenu); + menu->insertMenu(firstAction, m_layoutMenu); + menu->insertMenu(firstAction, m_gridMenu); + menu->insertSeparator(firstAction); + menu->insertMenu(firstAction, m_cartesianPlotMenu); + menu->insertSeparator(firstAction); } = void WorksheetView::fillToolBar(QToolBar* toolBar){ - toolBar->addSeparator(); - tbNewCartesianPlot =3D new QToolButton(toolBar); - tbNewCartesianPlot->setPopupMode(QToolButton::MenuButtonPopup); - tbNewCartesianPlot->setMenu(m_addNewCartesianPlotMenu); - tbNewCartesianPlot->setDefaultAction(addCartesianPlot1Action); - toolBar->addWidget(tbNewCartesianPlot); - toolBar->addAction(addTextLabelAction); - - toolBar->addSeparator(); - toolBar->addAction(verticalLayoutAction); - toolBar->addAction(horizontalLayoutAction); - toolBar->addAction(gridLayoutAction); - toolBar->addAction(breakLayoutAction); - - toolBar->addSeparator(); - toolBar->addAction(selectionModeAction); - toolBar->addAction(navigationModeAction); - toolBar->addAction(zoomSelectionModeAction); - tbZoom =3D new QToolButton(toolBar); - tbZoom->setPopupMode(QToolButton::MenuButtonPopup); - tbZoom->setMenu(m_zoomMenu); - tbZoom->setDefaultAction(currentZoomAction); - toolBar->addWidget(tbZoom); + toolBar->addSeparator(); + tbNewCartesianPlot =3D new QToolButton(toolBar); + tbNewCartesianPlot->setPopupMode(QToolButton::MenuButtonPopup); + tbNewCartesianPlot->setMenu(m_addNewCartesianPlotMenu); + tbNewCartesianPlot->setDefaultAction(addCartesianPlot1Action); + toolBar->addWidget(tbNewCartesianPlot); + toolBar->addAction(addTextLabelAction); + + toolBar->addSeparator(); + toolBar->addAction(verticalLayoutAction); + toolBar->addAction(horizontalLayoutAction); + toolBar->addAction(gridLayoutAction); + toolBar->addAction(breakLayoutAction); + + toolBar->addSeparator(); + toolBar->addAction(selectionModeAction); + toolBar->addAction(navigationModeAction); + toolBar->addAction(zoomSelectionModeAction); + tbZoom =3D new QToolButton(toolBar); + tbZoom->setPopupMode(QToolButton::MenuButtonPopup); + tbZoom->setMenu(m_zoomMenu); + tbZoom->setDefaultAction(currentZoomAction); + toolBar->addWidget(tbZoom); } = void WorksheetView::fillCartesianPlotToolBar(QToolBar* toolBar) { - toolBar->addAction(cartesianPlotSelectionModeAction); - toolBar->addAction(cartesianPlotZoomSelectionModeAction); - toolBar->addAction(cartesianPlotZoomXSelectionModeAction); - toolBar->addAction(cartesianPlotZoomYSelectionModeAction); - toolBar->addSeparator(); - toolBar->addAction(addCurveAction); - toolBar->addAction(addEquationCurveAction); - toolBar->addAction(addFitCurveAction); - toolBar->addAction(addLegendAction); - toolBar->addSeparator(); - toolBar->addAction(addHorizontalAxisAction); - toolBar->addAction(addVerticalAxisAction); - toolBar->addSeparator(); - toolBar->addAction(scaleAutoAction); - toolBar->addAction(scaleAutoXAction); - toolBar->addAction(scaleAutoYAction); - toolBar->addAction(zoomInAction); - toolBar->addAction(zoomOutAction); - toolBar->addAction(zoomInXAction); - toolBar->addAction(zoomOutXAction); - toolBar->addAction(zoomInYAction); - toolBar->addAction(zoomOutYAction); - toolBar->addAction(shiftLeftXAction); - toolBar->addAction(shiftRightXAction); - toolBar->addAction(shiftUpYAction); - toolBar->addAction(shiftDownYAction); + toolBar->addAction(cartesianPlotSelectionModeAction); + toolBar->addAction(cartesianPlotZoomSelectionModeAction); + toolBar->addAction(cartesianPlotZoomXSelectionModeAction); + toolBar->addAction(cartesianPlotZoomYSelectionModeAction); + toolBar->addSeparator(); + toolBar->addAction(addCurveAction); + toolBar->addAction(addEquationCurveAction); + toolBar->addAction(addFitCurveAction); + toolBar->addAction(addLegendAction); + toolBar->addSeparator(); + toolBar->addAction(addHorizontalAxisAction); + toolBar->addAction(addVerticalAxisAction); + toolBar->addSeparator(); + toolBar->addAction(scaleAutoAction); + toolBar->addAction(scaleAutoXAction); + toolBar->addAction(scaleAutoYAction); + toolBar->addAction(zoomInAction); + toolBar->addAction(zoomOutAction); + toolBar->addAction(zoomInXAction); + toolBar->addAction(zoomOutXAction); + toolBar->addAction(zoomInYAction); + toolBar->addAction(zoomOutYAction); + toolBar->addAction(shiftLeftXAction); + toolBar->addAction(shiftRightXAction); + toolBar->addAction(shiftUpYAction); + toolBar->addAction(shiftDownYAction); } = void WorksheetView::setScene(QGraphicsScene* scene) { @@ -498,487 +498,487 @@ void WorksheetView::setScene(QGraphicsScene* scene)= { } = void WorksheetView::drawForeground(QPainter* painter, const QRectF& rect) { - if (m_mouseMode=3D=3DZoomSelectionMode && m_selectionBandIsShown) { - painter->save(); - const QRectF& selRect =3D mapToScene(QRect(m_selectionStart, m_selection= End).normalized()).boundingRect(); - painter->setPen(QPen(Qt::black, 5)); - painter->drawRect(selRect); - painter->setBrush(Qt::blue); - painter->setOpacity(0.2); - painter->drawRect(selRect); - painter->restore(); - } - QGraphicsView::drawForeground(painter, rect); + if (m_mouseMode=3D=3DZoomSelectionMode && m_selectionBandIsShown) { + painter->save(); + const QRectF& selRect =3D mapToScene(QRect(m_selectionStart, m_sel= ectionEnd).normalized()).boundingRect(); + painter->setPen(QPen(Qt::black, 5)); + painter->drawRect(selRect); + painter->setBrush(Qt::blue); + painter->setOpacity(0.2); + painter->drawRect(selRect); + painter->restore(); + } + QGraphicsView::drawForeground(painter, rect); } = void WorksheetView::drawBackground(QPainter* painter, const QRectF& rect) { - painter->save(); - - //painter->setRenderHint(QPainter::Antialiasing); - QRectF scene_rect =3D sceneRect(); - - if (!m_worksheet->useViewSize()) { - // background - if (!scene_rect.contains(rect)) - painter->fillRect(rect, Qt::lightGray); - - //shadow - int shadowSize =3D scene_rect.width()*0.02; - QRectF rightShadowRect(scene_rect.right(), scene_rect.top() + shadowSize, - shadowSize, scene_rect.height()); - QRectF bottomShadowRect(scene_rect.left() + shadowSize, scene_rect.botto= m(), - scene_rect.width(), shadowSize); - - painter->fillRect(rightShadowRect.intersected(rect), Qt::darkGray); - painter->fillRect(bottomShadowRect.intersected(rect), Qt::darkGray); - } - - // canvas - painter->setOpacity(m_worksheet->backgroundOpacity()); - if (m_worksheet->backgroundType() =3D=3D PlotArea::Color){ - switch (m_worksheet->backgroundColorStyle()){ - case PlotArea::SingleColor:{ - painter->setBrush(QBrush(m_worksheet->backgroundFirstColor())); - break; - } - case PlotArea::HorizontalLinearGradient:{ - QLinearGradient linearGrad(scene_rect.topLeft(), scene_rect.topRight()= ); - linearGrad.setColorAt(0, m_worksheet->backgroundFirstColor()); - linearGrad.setColorAt(1, m_worksheet->backgroundSecondColor()); - painter->setBrush(QBrush(linearGrad)); - break; - } - case PlotArea::VerticalLinearGradient:{ - QLinearGradient linearGrad(scene_rect.topLeft(), scene_rect.bottomLeft= ()); - linearGrad.setColorAt(0, m_worksheet->backgroundFirstColor()); - linearGrad.setColorAt(1, m_worksheet->backgroundSecondColor()); - painter->setBrush(QBrush(linearGrad)); - break; - } - case PlotArea::TopLeftDiagonalLinearGradient:{ - QLinearGradient linearGrad(scene_rect.topLeft(), scene_rect.bottomRigh= t()); - linearGrad.setColorAt(0, m_worksheet->backgroundFirstColor()); - linearGrad.setColorAt(1, m_worksheet->backgroundSecondColor()); - painter->setBrush(QBrush(linearGrad)); - break; - } - case PlotArea::BottomLeftDiagonalLinearGradient:{ - QLinearGradient linearGrad(scene_rect.bottomLeft(), scene_rect.topRigh= t()); - linearGrad.setColorAt(0, m_worksheet->backgroundFirstColor()); - linearGrad.setColorAt(1, m_worksheet->backgroundSecondColor()); - painter->setBrush(QBrush(linearGrad)); - break; - } - case PlotArea::RadialGradient:{ - QRadialGradient radialGrad(scene_rect.center(), scene_rect.width()/2); - radialGrad.setColorAt(0, m_worksheet->backgroundFirstColor()); - radialGrad.setColorAt(1, m_worksheet->backgroundSecondColor()); - painter->setBrush(QBrush(radialGrad)); - break; - } - default: - painter->setBrush(QBrush(m_worksheet->backgroundFirstColor())); - } - painter->drawRect(scene_rect); - }else if (m_worksheet->backgroundType() =3D=3D PlotArea::Image){ - const QString& backgroundFileName =3D m_worksheet->backgroundFileName().= trimmed(); - if ( !backgroundFileName.isEmpty() ) { - QPixmap pix(backgroundFileName); - switch (m_worksheet->backgroundImageStyle()){ - case PlotArea::ScaledCropped: - pix =3D pix.scaled(scene_rect.size().toSize(),Qt::KeepAspectRatioByEx= panding,Qt::SmoothTransformation); - painter->drawPixmap(scene_rect.topLeft(),pix); - break; - case PlotArea::Scaled: - pix =3D pix.scaled(scene_rect.size().toSize(),Qt::IgnoreAspectRatio,Q= t::SmoothTransformation); - painter->drawPixmap(scene_rect.topLeft(),pix); - break; - case PlotArea::ScaledAspectRatio: - pix =3D pix.scaled(scene_rect.size().toSize(),Qt::KeepAspectRatio,Qt:= :SmoothTransformation); - painter->drawPixmap(scene_rect.topLeft(),pix); - break; - case PlotArea::Centered: - painter->drawPixmap(QPointF(scene_rect.center().x()-pix.size().width(= )/2,scene_rect.center().y()-pix.size().height()/2),pix); - break; - case PlotArea::Tiled: - painter->drawTiledPixmap(scene_rect,pix); - break; - case PlotArea::CenterTiled: - painter->drawTiledPixmap(scene_rect,pix,QPoint(scene_rect.size().widt= h()/2,scene_rect.size().height()/2)); - break; - default: - painter->drawPixmap(scene_rect.topLeft(),pix); - } - } - }else if (m_worksheet->backgroundType() =3D=3D PlotArea::Pattern){ - painter->setBrush(QBrush(m_worksheet->backgroundFirstColor(),m_worksheet= ->backgroundBrushStyle())); - painter->drawRect(scene_rect); - } + painter->save(); + + //painter->setRenderHint(QPainter::Antialiasing); + QRectF scene_rect =3D sceneRect(); + + if (!m_worksheet->useViewSize()) { + // background + if (!scene_rect.contains(rect)) + painter->fillRect(rect, Qt::lightGray); + + //shadow + int shadowSize =3D scene_rect.width()*0.02; + QRectF rightShadowRect(scene_rect.right(), scene_rect.top() + shad= owSize, + shadowSize, scene_rect.height(= )); + QRectF bottomShadowRect(scene_rect.left() + shadowSize, scene_rect= .bottom(), + scene_rect.width(), shadowSize= ); + + painter->fillRect(rightShadowRect.intersected(rect), Qt::darkGray); + painter->fillRect(bottomShadowRect.intersected(rect), Qt::darkGray= ); + } + + // canvas + painter->setOpacity(m_worksheet->backgroundOpacity()); + if (m_worksheet->backgroundType() =3D=3D PlotArea::Color){ + switch (m_worksheet->backgroundColorStyle()){ + case PlotArea::SingleColor:{ + painter->setBrush(QBrush(m_worksheet->backgroundFirstColor= ())); + break; + } + case PlotArea::HorizontalLinearGradient:{ + QLinearGradient linearGrad(scene_rect.topLeft(), scene_rec= t.topRight()); + linearGrad.setColorAt(0, m_worksheet->backgroundFirstColor= ()); + linearGrad.setColorAt(1, m_worksheet->backgroundSecondColo= r()); + painter->setBrush(QBrush(linearGrad)); + break; + } + case PlotArea::VerticalLinearGradient:{ + QLinearGradient linearGrad(scene_rect.topLeft(), scene_rec= t.bottomLeft()); + linearGrad.setColorAt(0, m_worksheet->backgroundFirstColor= ()); + linearGrad.setColorAt(1, m_worksheet->backgroundSecondColo= r()); + painter->setBrush(QBrush(linearGrad)); + break; + } + case PlotArea::TopLeftDiagonalLinearGradient:{ + QLinearGradient linearGrad(scene_rect.topLeft(), scene_rec= t.bottomRight()); + linearGrad.setColorAt(0, m_worksheet->backgroundFirstColor= ()); + linearGrad.setColorAt(1, m_worksheet->backgroundSecondColo= r()); + painter->setBrush(QBrush(linearGrad)); + break; + } + case PlotArea::BottomLeftDiagonalLinearGradient:{ + QLinearGradient linearGrad(scene_rect.bottomLeft(), scene_= rect.topRight()); + linearGrad.setColorAt(0, m_worksheet->backgroundFirstColor= ()); + linearGrad.setColorAt(1, m_worksheet->backgroundSecondColo= r()); + painter->setBrush(QBrush(linearGrad)); + break; + } + case PlotArea::RadialGradient:{ + QRadialGradient radialGrad(scene_rect.center(), scene_rect= .width()/2); + radialGrad.setColorAt(0, m_worksheet->backgroundFirstColor= ()); + radialGrad.setColorAt(1, m_worksheet->backgroundSecondColo= r()); + painter->setBrush(QBrush(radialGrad)); + break; + } + default: + painter->setBrush(QBrush(m_worksheet->backgroundFirstColor= ())); + } + painter->drawRect(scene_rect); + }else if (m_worksheet->backgroundType() =3D=3D PlotArea::Image){ + const QString& backgroundFileName =3D m_worksheet->backgroundFileN= ame().trimmed(); + if ( !backgroundFileName.isEmpty() ) { + QPixmap pix(backgroundFileName); + switch (m_worksheet->backgroundImageStyle()){ + case PlotArea::ScaledCropped: + pix =3D pix.scaled(scene_rect.size().toSize(),Qt::Keep= AspectRatioByExpanding,Qt::SmoothTransformation); + painter->drawPixmap(scene_rect.topLeft(),pix); + break; + case PlotArea::Scaled: + pix =3D pix.scaled(scene_rect.size().toSize(),Qt::Igno= reAspectRatio,Qt::SmoothTransformation); + painter->drawPixmap(scene_rect.topLeft(),pix); + break; + case PlotArea::ScaledAspectRatio: + pix =3D pix.scaled(scene_rect.size().toSize(),Qt::Keep= AspectRatio,Qt::SmoothTransformation); + painter->drawPixmap(scene_rect.topLeft(),pix); + break; + case PlotArea::Centered: + painter->drawPixmap(QPointF(scene_rect.center().x()-pi= x.size().width()/2,scene_rect.center().y()-pix.size().height()/2),pix); + break; + case PlotArea::Tiled: + painter->drawTiledPixmap(scene_rect,pix); + break; + case PlotArea::CenterTiled: + painter->drawTiledPixmap(scene_rect,pix,QPoint(scene_r= ect.size().width()/2,scene_rect.size().height()/2)); + break; + default: + painter->drawPixmap(scene_rect.topLeft(),pix); + } + } + }else if (m_worksheet->backgroundType() =3D=3D PlotArea::Pattern){ + painter->setBrush(QBrush(m_worksheet->backgroundFirstColor(),m_wor= ksheet->backgroundBrushStyle())); + painter->drawRect(scene_rect); + } = //grid - if (m_gridSettings.style !=3D WorksheetView::NoGrid){ - QColor c=3Dm_gridSettings.color; - c.setAlphaF(m_gridSettings.opacity); - painter->setPen(c); - - qreal x, y; - qreal left =3D scene_rect.left(); - qreal right =3D scene_rect.right(); - qreal top =3D scene_rect.top(); - qreal bottom =3D scene_rect.bottom(); - - if (m_gridSettings.style=3D=3DWorksheetView::LineGrid){ - QLineF line; - - //horizontal lines - y =3D top + m_gridSettings.verticalSpacing; - while (y < bottom) { - line.setLine( left, y, right, y ); - painter->drawLine(line); - y +=3D m_gridSettings.verticalSpacing; - } - - //vertical lines - x =3D left + m_gridSettings.horizontalSpacing; - while (x < right) { - line.setLine( x, top, x, bottom ); - painter->drawLine(line); - x +=3D m_gridSettings.horizontalSpacing; - } - }else{ //DotGrid - y =3D top + m_gridSettings.verticalSpacing; - while (y < bottom){ - x =3D left;// + m_gridSettings.horizontalSpacing; - while (x < right){ - x +=3D m_gridSettings.horizontalSpacing; - painter->drawPoint(x, y); - } - y +=3D m_gridSettings.verticalSpacing; - } - } - } - - invalidateScene(rect, QGraphicsScene::BackgroundLayer); - painter->restore(); + if (m_gridSettings.style !=3D WorksheetView::NoGrid){ + QColor c=3Dm_gridSettings.color; + c.setAlphaF(m_gridSettings.opacity); + painter->setPen(c); + + qreal x, y; + qreal left =3D scene_rect.left(); + qreal right =3D scene_rect.right(); + qreal top =3D scene_rect.top(); + qreal bottom =3D scene_rect.bottom(); + + if (m_gridSettings.style=3D=3DWorksheetView::LineGrid){ + QLineF line; + + //horizontal lines + y =3D top + m_gridSettings.verticalSpacing; + while (y < bottom) { + line.setLine( left, y, right, y ); + painter->drawLine(line); + y +=3D m_gridSettings.verticalSpacing; + } + + //vertical lines + x =3D left + m_gridSettings.horizontalSpacing; + while (x < right) { + line.setLine( x, top, x, bottom ); + painter->drawLine(line); + x +=3D m_gridSettings.horizontalSpacing; + } + }else{ //DotGrid + y =3D top + m_gridSettings.verticalSpacing; + while (y < bottom){ + x =3D left;// + m_gridSettings.horizontalSpacing; + while (x < right){ + x +=3D m_gridSettings.horizontalSpacing; + painter->drawPoint(x, y); + } + y +=3D m_gridSettings.verticalSpacing; + } + } + } + + invalidateScene(rect, QGraphicsScene::BackgroundLayer); + painter->restore(); } = //########################################################################= ###### //#################################### Events #########################= ###### //########################################################################= ###### void WorksheetView::resizeEvent(QResizeEvent *event) { - if (m_worksheet->useViewSize()) - this->processResize(); + if (m_worksheet->useViewSize()) + this->processResize(); = - QGraphicsView::resizeEvent(event); + QGraphicsView::resizeEvent(event); } = void WorksheetView::wheelEvent(QWheelEvent *event) { if (m_mouseMode =3D=3D ZoomSelectionMode){ - if (event->delta() > 0) - scale(1.2, 1.2); - else if (event->delta() < 0) - scale(1.0/1.2, 1.0/1.2); + if (event->delta() > 0) + scale(1.2, 1.2); + else if (event->delta() < 0) + scale(1.0/1.2, 1.0/1.2); }else{ - QGraphicsView::wheelEvent(event); + QGraphicsView::wheelEvent(event); } } = void WorksheetView::mousePressEvent(QMouseEvent* event) { - if (m_mouseMode =3D=3D ZoomSelectionMode) { - m_selectionStart =3D event->pos(); - m_selectionBandIsShown =3D true; - } - - //prevent the deselection of items when context menu event - //was triggered (right button click) - if (event->button() !=3D Qt::LeftButton) { + if (m_mouseMode =3D=3D ZoomSelectionMode) { + m_selectionStart =3D event->pos(); + m_selectionBandIsShown =3D true; + } + + //prevent the deselection of items when context menu event + //was triggered (right button click) + if (event->button() !=3D Qt::LeftButton) { event->accept(); return; } = - // select the worksheet in the project explorer if the view was clicked - // and there is no selection currently. We need this for the case when - // there is a single worksheet in the project and we change from the proj= ect-node - // in the project explorer to the worksheet-node by clicking the view. - if ( scene()->selectedItems().empty() ) - m_worksheet->setSelectedInView(true); + // select the worksheet in the project explorer if the view was clicked + // and there is no selection currently. We need this for the case when + // there is a single worksheet in the project and we change from the p= roject-node + // in the project explorer to the worksheet-node by clicking the view. + if ( scene()->selectedItems().empty() ) + m_worksheet->setSelectedInView(true); = - QGraphicsView::mousePressEvent(event); + QGraphicsView::mousePressEvent(event); } = void WorksheetView::mouseReleaseEvent(QMouseEvent* event) { - if (m_mouseMode =3D=3D ZoomSelectionMode) { - m_selectionBandIsShown =3D false; - viewport()->repaint(QRect(m_selectionStart, m_selectionEnd).normalized()= ); - - //don't zoom if very small region was selected, avoid occasional/unwante= d zooming - m_selectionEnd =3D event->pos(); - if ( abs(m_selectionEnd.x()-m_selectionStart.x())>20 && abs(m_selectionE= nd.y()-m_selectionStart.y())>20 ) - fitInView(mapToScene(QRect(m_selectionStart, m_selectionEnd).normalized= ()).boundingRect(), Qt::KeepAspectRatio); - } - QGraphicsView::mouseReleaseEvent(event); + if (m_mouseMode =3D=3D ZoomSelectionMode) { + m_selectionBandIsShown =3D false; + viewport()->repaint(QRect(m_selectionStart, m_selectionEnd).normal= ized()); + + //don't zoom if very small region was selected, avoid occasional/u= nwanted zooming + m_selectionEnd =3D event->pos(); + if ( abs(m_selectionEnd.x()-m_selectionStart.x())>20 && abs(m_sele= ctionEnd.y()-m_selectionStart.y())>20 ) + fitInView(mapToScene(QRect(m_selectionStart, m_selectionEnd).n= ormalized()).boundingRect(), Qt::KeepAspectRatio); + } + QGraphicsView::mouseReleaseEvent(event); } = void WorksheetView::mouseMoveEvent(QMouseEvent* event) { - if (m_mouseMode =3D=3D SelectionMode && m_cartesianPlotMouseMode !=3D Car= tesianPlot::SelectionMode ) { - //check whether there is a cartesian plot under the cursor - bool plot =3D false; - QGraphicsItem* item =3D itemAt(event->pos()); - if (item) { - plot =3D item->data(0).toInt() =3D=3D WorksheetElement::NameCartesianPl= ot; - if (!plot && item->parentItem()) - plot =3D item->parentItem()->data(0).toInt() =3D=3D WorksheetElement::= NameCartesianPlot; - } - - //set the cursor appearance according to the current mouse mode for the = cartesian plots - if (plot) { - if (m_cartesianPlotMouseMode =3D=3D CartesianPlot::ZoomSelectionMode) { - setCursor(Qt::CrossCursor); - } else if (m_cartesianPlotMouseMode =3D=3D CartesianPlot::ZoomXSelectio= nMode) { - setCursor(Qt::SizeHorCursor); - } else if (m_cartesianPlotMouseMode =3D=3D CartesianPlot::ZoomYSelectio= nMode) { - setCursor(Qt::SizeVerCursor); - } - } else { - setCursor(Qt::ArrowCursor); - } - } else if (m_mouseMode =3D=3D SelectionMode && m_cartesianPlotMouseMode = =3D=3D CartesianPlot::SelectionMode ) { - setCursor(Qt::ArrowCursor); - } else if (m_selectionBandIsShown) { - m_selectionEnd =3D event->pos(); - viewport()->repaint(QRect(m_selectionStart, m_selectionEnd).normalized()= ); - } - - QGraphicsView::mouseMoveEvent(event); + if (m_mouseMode =3D=3D SelectionMode && m_cartesianPlotMouseMode !=3D = CartesianPlot::SelectionMode ) { + //check whether there is a cartesian plot under the cursor + bool plot =3D false; + QGraphicsItem* item =3D itemAt(event->pos()); + if (item) { + plot =3D item->data(0).toInt() =3D=3D WorksheetElement::NameCa= rtesianPlot; + if (!plot && item->parentItem()) + plot =3D item->parentItem()->data(0).toInt() =3D=3D Worksh= eetElement::NameCartesianPlot; + } + + //set the cursor appearance according to the current mouse mode fo= r the cartesian plots + if (plot) { + if (m_cartesianPlotMouseMode =3D=3D CartesianPlot::ZoomSelecti= onMode) { + setCursor(Qt::CrossCursor); + } else if (m_cartesianPlotMouseMode =3D=3D CartesianPlot::Zoom= XSelectionMode) { + setCursor(Qt::SizeHorCursor); + } else if (m_cartesianPlotMouseMode =3D=3D CartesianPlot::Zoom= YSelectionMode) { + setCursor(Qt::SizeVerCursor); + } + } else { + setCursor(Qt::ArrowCursor); + } + } else if (m_mouseMode =3D=3D SelectionMode && m_cartesianPlotMouseMod= e =3D=3D CartesianPlot::SelectionMode ) { + setCursor(Qt::ArrowCursor); + } else if (m_selectionBandIsShown) { + m_selectionEnd =3D event->pos(); + viewport()->repaint(QRect(m_selectionStart, m_selectionEnd).normal= ized()); + } + + QGraphicsView::mouseMoveEvent(event); } = void WorksheetView::contextMenuEvent(QContextMenuEvent* e) { - if ( !itemAt(e->pos()) ){ - //no item under the cursor -> show the context menu for the worksheet - QMenu *menu =3D new QMenu(this); - this->createContextMenu(menu); - menu->exec(QCursor::pos()); - }else{ - //propagate the event to the scene and graphics items - QGraphicsView::contextMenuEvent(e); - } + if ( !itemAt(e->pos()) ){ + //no item under the cursor -> show the context menu for the worksh= eet + QMenu *menu =3D new QMenu(this); + this->createContextMenu(menu); + menu->exec(QCursor::pos()); + }else{ + //propagate the event to the scene and graphics items + QGraphicsView::contextMenuEvent(e); + } } = //########################################################################= ###### //#################################### SLOTs ##########################= ###### //########################################################################= ###### void WorksheetView::useViewSizeRequested() { - if (m_worksheet->useViewSize()) { - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - zoomFitPageHeightAction->setVisible(false); - zoomFitPageWidthAction->setVisible(false); - currentZoomAction =3D zoomInViewAction; - if (tbZoom) - tbZoom->setDefaultAction(zoomInViewAction); - - //determine and set the current view size - this->processResize(); - } else { - setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - zoomFitPageHeightAction->setVisible(true); - zoomFitPageWidthAction->setVisible(true); - } + if (m_worksheet->useViewSize()) { + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + zoomFitPageHeightAction->setVisible(false); + zoomFitPageWidthAction->setVisible(false); + currentZoomAction =3D zoomInViewAction; + if (tbZoom) + tbZoom->setDefaultAction(zoomInViewAction); + + //determine and set the current view size + this->processResize(); + } else { + setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + zoomFitPageHeightAction->setVisible(true); + zoomFitPageWidthAction->setVisible(true); + } } = void WorksheetView::processResize() { - if (size() !=3D sceneRect().size()) { - static const float hscale =3D QApplication::desktop()->physicalDpiX()/(2= 5.4*Worksheet::convertToSceneUnits(1,Worksheet::Millimeter)); - static const float vscale =3D QApplication::desktop()->physicalDpiY()/(2= 5.4*Worksheet::convertToSceneUnits(1,Worksheet::Millimeter)); - m_worksheet->setUndoAware(false); - m_worksheet->setPageRect(QRectF(0.0, 0.0, width()/hscale, height()/vscal= e)); - m_worksheet->setUndoAware(true); - } + if (size() !=3D sceneRect().size()) { + static const float hscale =3D QApplication::desktop()->physicalDpi= X()/(25.4*Worksheet::convertToSceneUnits(1,Worksheet::Millimeter)); + static const float vscale =3D QApplication::desktop()->physicalDpi= Y()/(25.4*Worksheet::convertToSceneUnits(1,Worksheet::Millimeter)); + m_worksheet->setUndoAware(false); + m_worksheet->setPageRect(QRectF(0.0, 0.0, width()/hscale, height()= /vscale)); + m_worksheet->setUndoAware(true); + } } = void WorksheetView::changeZoom(QAction* action){ - if (action=3D=3DzoomInViewAction){ - scale(1.2, 1.2); - }else if (action=3D=3DzoomOutViewAction){ - scale(1.0/1.2, 1.0/1.2); - }else if (action=3D=3DzoomOriginAction){ - static const float hscale =3D QApplication::desktop()->physicalDpiX()/(2= 5.4*Worksheet::convertToSceneUnits(1,Worksheet::Millimeter)); - static const float vscale =3D QApplication::desktop()->physicalDpiY()/(2= 5.4*Worksheet::convertToSceneUnits(1,Worksheet::Millimeter)); - setTransform(QTransform::fromScale(hscale, vscale)); - }else if (action=3D=3DzoomFitPageWidthAction){ - float scaleFactor =3D viewport()->width()/scene()->sceneRect().width(); - setTransform(QTransform::fromScale(scaleFactor, scaleFactor)); - }else if (action=3D=3DzoomFitPageHeightAction){ - float scaleFactor =3D viewport()->height()/scene()->sceneRect().height(); - setTransform(QTransform::fromScale(scaleFactor, scaleFactor)); - }else if (action=3D=3DzoomFitSelectionAction){ - fitInView(scene()->selectionArea().boundingRect(),Qt::KeepAspectRatio); - } - currentZoomAction=3Daction; - if (tbZoom) - tbZoom->setDefaultAction(action); + if (action=3D=3DzoomInViewAction){ + scale(1.2, 1.2); + }else if (action=3D=3DzoomOutViewAction){ + scale(1.0/1.2, 1.0/1.2); + }else if (action=3D=3DzoomOriginAction){ + static const float hscale =3D QApplication::desktop()->physicalDpi= X()/(25.4*Worksheet::convertToSceneUnits(1,Worksheet::Millimeter)); + static const float vscale =3D QApplication::desktop()->physicalDpi= Y()/(25.4*Worksheet::convertToSceneUnits(1,Worksheet::Millimeter)); + setTransform(QTransform::fromScale(hscale, vscale)); + }else if (action=3D=3DzoomFitPageWidthAction){ + float scaleFactor =3D viewport()->width()/scene()->sceneRect().wid= th(); + setTransform(QTransform::fromScale(scaleFactor, scaleFactor)); + }else if (action=3D=3DzoomFitPageHeightAction){ + float scaleFactor =3D viewport()->height()/scene()->sceneRect().he= ight(); + setTransform(QTransform::fromScale(scaleFactor, scaleFactor)); + }else if (action=3D=3DzoomFitSelectionAction){ + fitInView(scene()->selectionArea().boundingRect(),Qt::KeepAspectRa= tio); + } + currentZoomAction=3Daction; + if (tbZoom) + tbZoom->setDefaultAction(action); } = void WorksheetView::mouseModeChanged(QAction* action) { - if (action=3D=3DselectionModeAction) { - m_mouseMode =3D SelectionMode; - setInteractive(true); - setDragMode(QGraphicsView::NoDrag); - } else if (action=3D=3DnavigationModeAction) { - m_mouseMode =3D NavigationMode; - setInteractive(false); - setDragMode(QGraphicsView::ScrollHandDrag); - } else { - m_mouseMode =3D ZoomSelectionMode; - setInteractive(false); - setDragMode(QGraphicsView::NoDrag); - } + if (action=3D=3DselectionModeAction) { + m_mouseMode =3D SelectionMode; + setInteractive(true); + setDragMode(QGraphicsView::NoDrag); + } else if (action=3D=3DnavigationModeAction) { + m_mouseMode =3D NavigationMode; + setInteractive(false); + setDragMode(QGraphicsView::ScrollHandDrag); + } else { + m_mouseMode =3D ZoomSelectionMode; + setInteractive(false); + setDragMode(QGraphicsView::NoDrag); + } } = //"Add new" related slots void WorksheetView::addNew(QAction* action){ - WorksheetElement* aspect =3D 0; - if ( action =3D=3D addCartesianPlot1Action ){ - CartesianPlot* plot =3D new CartesianPlot(i18n("xy-plot")); - plot->initDefault(CartesianPlot::FourAxes); - plot->setMouseMode(m_cartesianPlotMouseMode); - aspect =3D plot; - if (tbNewCartesianPlot) - tbNewCartesianPlot->setDefaultAction(addCartesianPlot1Action); - }else if ( action =3D=3D addCartesianPlot2Action ){ - CartesianPlot* plot =3D new CartesianPlot(i18n("xy-plot")); - plot->initDefault(CartesianPlot::TwoAxes); - plot->setMouseMode(m_cartesianPlotMouseMode); - aspect =3D plot; - if (tbNewCartesianPlot) - tbNewCartesianPlot->setDefaultAction(addCartesianPlot2Action); - }else if ( action =3D=3D addCartesianPlot3Action ){ - CartesianPlot* plot =3D new CartesianPlot(i18n("xy-plot")); - plot->initDefault(CartesianPlot::TwoAxesCentered); - plot->setMouseMode(m_cartesianPlotMouseMode); - aspect =3D plot; - if (tbNewCartesianPlot) - tbNewCartesianPlot->setDefaultAction(addCartesianPlot3Action); - }else if ( action =3D=3D addCartesianPlot4Action ){ - CartesianPlot* plot =3D new CartesianPlot(i18n("xy-plot")); - plot->initDefault(CartesianPlot::TwoAxesCenteredZero); - plot->setMouseMode(m_cartesianPlotMouseMode); - aspect =3D plot; - if (tbNewCartesianPlot) - tbNewCartesianPlot->setDefaultAction(addCartesianPlot4Action); - }else if ( action =3D=3D addTextLabelAction ){ - TextLabel* l =3D new TextLabel(i18n("text label")); - l->setText(i18n("text label")); - aspect =3D l; - } - - if (!aspect) - return; - - m_worksheet->addChild(aspect); - handleCartesianPlotActions(); - - if (!m_fadeInTimeLine) { - m_fadeInTimeLine =3D new QTimeLine(1000, this); - m_fadeInTimeLine->setFrameRange(0, 100); - connect(m_fadeInTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT(fadeIn= (qreal))); - } - - //if there is already an element fading in, stop the time line and show t= he element with the full opacity. - if (m_fadeInTimeLine->state() =3D=3D QTimeLine::Running) { - m_fadeInTimeLine->stop(); - QGraphicsOpacityEffect* effect =3D new QGraphicsOpacityEffect(); - effect->setOpacity(1); - lastAddedWorksheetElement->graphicsItem()->setGraphicsEffect(effect); - } - - //fade-in the newly added element - lastAddedWorksheetElement =3D aspect; - QGraphicsOpacityEffect* effect =3D new QGraphicsOpacityEffect(); - effect->setOpacity(0); - lastAddedWorksheetElement->graphicsItem()->setGraphicsEffect(effect); - m_fadeInTimeLine->start(); + WorksheetElement* aspect =3D 0; + if ( action =3D=3D addCartesianPlot1Action ){ + CartesianPlot* plot =3D new CartesianPlot(i18n("xy-plot")); + plot->initDefault(CartesianPlot::FourAxes); + plot->setMouseMode(m_cartesianPlotMouseMode); + aspect =3D plot; + if (tbNewCartesianPlot) + tbNewCartesianPlot->setDefaultAction(addCartesianPlot1Action); + }else if ( action =3D=3D addCartesianPlot2Action ){ + CartesianPlot* plot =3D new CartesianPlot(i18n("xy-plot")); + plot->initDefault(CartesianPlot::TwoAxes); + plot->setMouseMode(m_cartesianPlotMouseMode); + aspect =3D plot; + if (tbNewCartesianPlot) + tbNewCartesianPlot->setDefaultAction(addCartesianPlot2Action); + }else if ( action =3D=3D addCartesianPlot3Action ){ + CartesianPlot* plot =3D new CartesianPlot(i18n("xy-plot")); + plot->initDefault(CartesianPlot::TwoAxesCentered); + plot->setMouseMode(m_cartesianPlotMouseMode); + aspect =3D plot; + if (tbNewCartesianPlot) + tbNewCartesianPlot->setDefaultAction(addCartesianPlot3Action); + }else if ( action =3D=3D addCartesianPlot4Action ){ + CartesianPlot* plot =3D new CartesianPlot(i18n("xy-plot")); + plot->initDefault(CartesianPlot::TwoAxesCenteredZero); + plot->setMouseMode(m_cartesianPlotMouseMode); + aspect =3D plot; + if (tbNewCartesianPlot) + tbNewCartesianPlot->setDefaultAction(addCartesianPlot4Action); + }else if ( action =3D=3D addTextLabelAction ){ + TextLabel* l =3D new TextLabel(i18n("text label")); + l->setText(i18n("text label")); + aspect =3D l; + } + + if (!aspect) + return; + + m_worksheet->addChild(aspect); + handleCartesianPlotActions(); + + if (!m_fadeInTimeLine) { + m_fadeInTimeLine =3D new QTimeLine(1000, this); + m_fadeInTimeLine->setFrameRange(0, 100); + connect(m_fadeInTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT(= fadeIn(qreal))); + } + + //if there is already an element fading in, stop the time line and sho= w the element with the full opacity. + if (m_fadeInTimeLine->state() =3D=3D QTimeLine::Running) { + m_fadeInTimeLine->stop(); + QGraphicsOpacityEffect* effect =3D new QGraphicsOpacityEffect(); + effect->setOpacity(1); + lastAddedWorksheetElement->graphicsItem()->setGraphicsEffect(effec= t); + } + + //fade-in the newly added element + lastAddedWorksheetElement =3D aspect; + QGraphicsOpacityEffect* effect =3D new QGraphicsOpacityEffect(); + effect->setOpacity(0); + lastAddedWorksheetElement->graphicsItem()->setGraphicsEffect(effect); + m_fadeInTimeLine->start(); } = /*! * select all top-level items */ void WorksheetView::selectAllElements() { - //deselect all previously selected items since there can be some non top-= level items belong them - m_suppressSelectionChangedEvent =3D true; - QList items =3D scene()->selectedItems(); - foreach ( QGraphicsItem* item , m_selectedItems ){ - m_worksheet->setItemSelectedInView(item, false); - } - - //select top-level items - items =3D scene()->items(); - foreach(QGraphicsItem* item, items){ - if (!item->parentItem()) - item->setSelected(true); - } - m_suppressSelectionChangedEvent =3D false; - this->selectionChanged(); + //deselect all previously selected items since there can be some non t= op-level items belong them + m_suppressSelectionChangedEvent =3D true; + QList items =3D scene()->selectedItems(); + foreach ( QGraphicsItem* item , m_selectedItems ){ + m_worksheet->setItemSelectedInView(item, false); + } + + //select top-level items + items =3D scene()->items(); + foreach(QGraphicsItem* item, items){ + if (!item->parentItem()) + item->setSelected(true); + } + m_suppressSelectionChangedEvent =3D false; + this->selectionChanged(); } = /*! * deletes selected worksheet elements */ void WorksheetView::deleteElement() { - QList items =3D scene()->selectedItems(); - if (items.size()=3D=3D0) - return; - - int rc =3D KMessageBox::warningYesNo( this, - i18np("Do you really want to delete the selected object?", "Do you real= ly want to delete the selected %1 objects?", items.size()), - i18n("Delete selected objects")); - - if (rc=3D=3DKMessageBox::No) - return; - - m_suppressSelectionChangedEvent =3D true; - m_worksheet->beginMacro(i18n("%1: Remove selected worksheet elements.", m= _worksheet->name())); - foreach ( QGraphicsItem* item , m_selectedItems ) { - m_worksheet->deleteAspectFromGraphicsItem(item); - } - m_worksheet->endMacro(); - m_suppressSelectionChangedEvent =3D false; + QList items =3D scene()->selectedItems(); + if (items.size()=3D=3D0) + return; + + int rc =3D KMessageBox::warningYesNo( this, + i18np("Do you really want to delete the selected object?", "Do= you really want to delete the selected %1 objects?", items.size()), + i18n("Delete selected objects")); + + if (rc=3D=3DKMessageBox::No) + return; + + m_suppressSelectionChangedEvent =3D true; + m_worksheet->beginMacro(i18n("%1: Remove selected worksheet elements."= , m_worksheet->name())); + foreach ( QGraphicsItem* item , m_selectedItems ) { + m_worksheet->deleteAspectFromGraphicsItem(item); + } + m_worksheet->endMacro(); + m_suppressSelectionChangedEvent =3D false; } = void WorksheetView::aspectAboutToBeRemoved(const AbstractAspect* aspect){ - lastAddedWorksheetElement =3D dynamic_cast(const_cast<= AbstractAspect*>(aspect)); - if (!lastAddedWorksheetElement) - return; + lastAddedWorksheetElement =3D dynamic_cast(const_ca= st(aspect)); + if (!lastAddedWorksheetElement) + return; = - //FIXME: fading-out doesn't work - //also, the following code collides with undo/redo of the deletion - //of a worksheet element (after redoing the element is not shown with the= full opacity + //FIXME: fading-out doesn't work + //also, the following code collides with undo/redo of the deletion + //of a worksheet element (after redoing the element is not shown with = the full opacity /* - if (!m_fadeOutTimeLine) { - m_fadeOutTimeLine =3D new QTimeLine(1000, this); - m_fadeOutTimeLine->setFrameRange(0, 100); - connect(m_fadeOutTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT(fadeO= ut(qreal))); - } + if (!m_fadeOutTimeLine) { + m_fadeOutTimeLine =3D new QTimeLine(1000, this); + m_fadeOutTimeLine->setFrameRange(0, 100); + connect(m_fadeOutTimeLine, SIGNAL(valueChanged(qreal)), this, SLOT= (fadeOut(qreal))); + } = - //if there is already an element fading out, stop the time line - if (m_fadeOutTimeLine->state() =3D=3D QTimeLine::Running) - m_fadeOutTimeLine->stop(); + //if there is already an element fading out, stop the time line + if (m_fadeOutTimeLine->state() =3D=3D QTimeLine::Running) + m_fadeOutTimeLine->stop(); = - m_fadeOutTimeLine->start(); + m_fadeOutTimeLine->start(); */ } = void WorksheetView::fadeIn(qreal value) { - QGraphicsOpacityEffect* effect =3D new QGraphicsOpacityEffect(); - effect->setOpacity(value); - lastAddedWorksheetElement->graphicsItem()->setGraphicsEffect(effect); + QGraphicsOpacityEffect* effect =3D new QGraphicsOpacityEffect(); + effect->setOpacity(value); + lastAddedWorksheetElement->graphicsItem()->setGraphicsEffect(effect); } = void WorksheetView::fadeOut(qreal value) { - QGraphicsOpacityEffect* effect =3D new QGraphicsOpacityEffect(); - effect->setOpacity(1-value); - lastAddedWorksheetElement->graphicsItem()->setGraphicsEffect(effect); + QGraphicsOpacityEffect* effect =3D new QGraphicsOpacityEffect(); + effect->setOpacity(1-value); + lastAddedWorksheetElement->graphicsItem()->setGraphicsEffect(effect); } = /*! @@ -986,82 +986,82 @@ void WorksheetView::fadeOut(qreal value) { * sets the layout in Worksheet and enables/disables the layout actions. */ void WorksheetView::changeLayout(QAction* action){ - if (action=3D=3DbreakLayoutAction){ - verticalLayoutAction->setEnabled(true); - verticalLayoutAction->setChecked(false); - - horizontalLayoutAction->setEnabled(true); - horizontalLayoutAction->setChecked(false); - - gridLayoutAction->setEnabled(true); - gridLayoutAction->setChecked(false); - - breakLayoutAction->setEnabled(false); - - m_worksheet->setLayout(Worksheet::NoLayout); - }else{ - verticalLayoutAction->setEnabled(false); - horizontalLayoutAction->setEnabled(false); - gridLayoutAction->setEnabled(false); - breakLayoutAction->setEnabled(true); - - if (action =3D=3D verticalLayoutAction){ - verticalLayoutAction->setChecked(true); - m_worksheet->setLayout(Worksheet::VerticalLayout); - }else if (action =3D=3D horizontalLayoutAction){ - horizontalLayoutAction->setChecked(true); - m_worksheet->setLayout(Worksheet::HorizontalLayout); - }else{ - gridLayoutAction->setChecked(true); - m_worksheet->setLayout(Worksheet::GridLayout); - } - } + if (action=3D=3DbreakLayoutAction){ + verticalLayoutAction->setEnabled(true); + verticalLayoutAction->setChecked(false); + + horizontalLayoutAction->setEnabled(true); + horizontalLayoutAction->setChecked(false); + + gridLayoutAction->setEnabled(true); + gridLayoutAction->setChecked(false); + + breakLayoutAction->setEnabled(false); + + m_worksheet->setLayout(Worksheet::NoLayout); + }else{ + verticalLayoutAction->setEnabled(false); + horizontalLayoutAction->setEnabled(false); + gridLayoutAction->setEnabled(false); + breakLayoutAction->setEnabled(true); + + if (action =3D=3D verticalLayoutAction){ + verticalLayoutAction->setChecked(true); + m_worksheet->setLayout(Worksheet::VerticalLayout); + }else if (action =3D=3D horizontalLayoutAction){ + horizontalLayoutAction->setChecked(true); + m_worksheet->setLayout(Worksheet::HorizontalLayout); + }else{ + gridLayoutAction->setChecked(true); + m_worksheet->setLayout(Worksheet::GridLayout); + } + } } = void WorksheetView::changeGrid(QAction* action){ - QString name =3D action->objectName(); - - if (name =3D=3D "noGridAction"){ - m_gridSettings.style =3D WorksheetView::NoGrid; - snapToGridAction->setEnabled(false); - }else if (name =3D=3D "sparseLineGridAction"){ - m_gridSettings.style =3D WorksheetView::LineGrid; - m_gridSettings.color =3D Qt::gray; - m_gridSettings.opacity =3D 0.7; - m_gridSettings.horizontalSpacing =3D 15; - m_gridSettings.verticalSpacing =3D 15; - }else if (name =3D=3D "denseLineGridAction"){ - m_gridSettings.style =3D WorksheetView::LineGrid; - m_gridSettings.color =3D Qt::gray; - m_gridSettings.opacity =3D 0.7; - m_gridSettings.horizontalSpacing =3D 5; - m_gridSettings.verticalSpacing =3D 5; - }else if (name =3D=3D "denseDotGridAction"){ - m_gridSettings.style =3D WorksheetView::DotGrid; - m_gridSettings.color =3D Qt::black; - m_gridSettings.opacity =3D 0.7; - m_gridSettings.horizontalSpacing =3D 5; - m_gridSettings.verticalSpacing =3D 5; - }else if (name =3D=3D "sparseDotGridAction"){ - m_gridSettings.style =3D WorksheetView::DotGrid; - m_gridSettings.color =3D Qt::black; - m_gridSettings.opacity =3D 0.7; - m_gridSettings.horizontalSpacing =3D 15; - m_gridSettings.verticalSpacing =3D 15; - }else if (name =3D=3D "customGridAction"){ - GridDialog* dlg =3D new GridDialog(this); - if (dlg->exec() =3D=3D QDialog::Accepted) - dlg->save(m_gridSettings); - else - return; - } - - if (m_gridSettings.style =3D=3D WorksheetView::NoGrid) - snapToGridAction->setEnabled(false); - else - snapToGridAction->setEnabled(true); - - invalidateScene(sceneRect(), QGraphicsScene::BackgroundLayer); + QString name =3D action->objectName(); + + if (name =3D=3D "noGridAction"){ + m_gridSettings.style =3D WorksheetView::NoGrid; + snapToGridAction->setEnabled(false); + }else if (name =3D=3D "sparseLineGridAction"){ + m_gridSettings.style =3D WorksheetView::LineGrid; + m_gridSettings.color =3D Qt::gray; + m_gridSettings.opacity =3D 0.7; + m_gridSettings.horizontalSpacing =3D 15; + m_gridSettings.verticalSpacing =3D 15; + }else if (name =3D=3D "denseLineGridAction"){ + m_gridSettings.style =3D WorksheetView::LineGrid; + m_gridSettings.color =3D Qt::gray; + m_gridSettings.opacity =3D 0.7; + m_gridSettings.horizontalSpacing =3D 5; + m_gridSettings.verticalSpacing =3D 5; + }else if (name =3D=3D "denseDotGridAction"){ + m_gridSettings.style =3D WorksheetView::DotGrid; + m_gridSettings.color =3D Qt::black; + m_gridSettings.opacity =3D 0.7; + m_gridSettings.horizontalSpacing =3D 5; + m_gridSettings.verticalSpacing =3D 5; + }else if (name =3D=3D "sparseDotGridAction"){ + m_gridSettings.style =3D WorksheetView::DotGrid; + m_gridSettings.color =3D Qt::black; + m_gridSettings.opacity =3D 0.7; + m_gridSettings.horizontalSpacing =3D 15; + m_gridSettings.verticalSpacing =3D 15; + }else if (name =3D=3D "customGridAction"){ + GridDialog* dlg =3D new GridDialog(this); + if (dlg->exec() =3D=3D QDialog::Accepted) + dlg->save(m_gridSettings); + else + return; + } + + if (m_gridSettings.style =3D=3D WorksheetView::NoGrid) + snapToGridAction->setEnabled(false); + else + snapToGridAction->setEnabled(true); + + invalidateScene(sceneRect(), QGraphicsScene::BackgroundLayer); } = //TODO @@ -1075,11 +1075,11 @@ void WorksheetView::changeSnapToGrid(){ * and is finally handled here. */ void WorksheetView::selectItem(QGraphicsItem* item){ - m_suppressSelectionChangedEvent =3D true; - item->setSelected(true); - m_selectedItems<setSelected(true); + m_selectedItems<setSelected(false); - m_selectedItems.removeOne(item); - handleCartesianPlotActions(); - m_suppressSelectionChangedEvent =3D false; + m_suppressSelectionChangedEvent =3D true; + item->setSelected(false); + m_selectedItems.removeOne(item); + handleCartesianPlotActions(); + m_suppressSelectionChangedEvent =3D false; } = /*! @@ -1101,187 +1101,187 @@ void WorksheetView::deselectItem(QGraphicsItem* i= tem){ * and forwards these changes to \c Worksheet */ void WorksheetView::selectionChanged(){ - if (m_suppressSelectionChangedEvent) - return; - - QList items =3D scene()->selectedItems(); - - //When making a graphics item invisible, it gets deselected in the scene. - //In this case we don't want to deselect the item in the project explorer. - bool invisibleDeselected =3D false; - - //check, whether the previously selected items were deselected now. - //Forward the deselection prior to the selection of new items - //in order to avoid the unwanted multiple selection in project explorer - foreach ( QGraphicsItem* item, m_selectedItems ){ - if ( items.indexOf(item) =3D=3D -1 ) { - if (item->isVisible()) - m_worksheet->setItemSelectedInView(item, false); - else - invisibleDeselected =3D true; - } - } - - //select new items - if (items.size() =3D=3D 0 && invisibleDeselected =3D=3D false){ - //no items selected -> select the worksheet again. - m_worksheet->setSelectedInView(true); - }else{ - foreach (const QGraphicsItem* item, items) - m_worksheet->setItemSelectedInView(item, true); - - //items selected -> deselect the worksheet in the project explorer - //prevents unwanted multiple selection with worksheet (if it was selecte= d before) - m_worksheet->setSelectedInView(false); - } - - m_selectedItems =3D items; - handleCartesianPlotActions(); + if (m_suppressSelectionChangedEvent) + return; + + QList items =3D scene()->selectedItems(); + + //When making a graphics item invisible, it gets deselected in the sce= ne. + //In this case we don't want to deselect the item in the project explo= rer. + bool invisibleDeselected =3D false; + + //check, whether the previously selected items were deselected now. + //Forward the deselection prior to the selection of new items + //in order to avoid the unwanted multiple selection in project explorer + foreach ( QGraphicsItem* item, m_selectedItems ){ + if ( items.indexOf(item) =3D=3D -1 ) { + if (item->isVisible()) + m_worksheet->setItemSelectedInView(item, false); + else + invisibleDeselected =3D true; + } + } + + //select new items + if (items.size() =3D=3D 0 && invisibleDeselected =3D=3D false){ + //no items selected -> select the worksheet again. + m_worksheet->setSelectedInView(true); + }else{ + foreach (const QGraphicsItem* item, items) + m_worksheet->setItemSelectedInView(item, true); + + //items selected -> deselect the worksheet in the project explorer + //prevents unwanted multiple selection with worksheet (if it was s= elected before) + m_worksheet->setSelectedInView(false); + } + + m_selectedItems =3D items; + handleCartesianPlotActions(); } = //check whether we have cartesian plots selected and activate/deactivate void WorksheetView::handleCartesianPlotActions() { - bool plot =3D false; - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - //check whether we have cartesian plots selected - foreach (QGraphicsItem* item , m_selectedItems) { - if (item->data(0).toInt() =3D=3D WorksheetElement::NameCartesianPlot) { - plot =3D true; - break; - } - } - } else { - //actions are applied to all available plots -> check whether we have pl= ots - plot =3D (m_worksheet->children().size() !=3D 0); - } - - cartesianPlotSelectionModeAction->setEnabled(plot); - cartesianPlotZoomSelectionModeAction->setEnabled(plot); - cartesianPlotZoomXSelectionModeAction->setEnabled(plot); - cartesianPlotZoomYSelectionModeAction->setEnabled(plot); - - addCurveAction->setEnabled(plot); - addEquationCurveAction->setEnabled(plot); - addFitCurveAction->setEnabled(plot); - addHorizontalAxisAction->setEnabled(plot); - addVerticalAxisAction->setEnabled(plot); - addLegendAction->setEnabled(plot); - - scaleAutoXAction->setEnabled(plot); - scaleAutoYAction->setEnabled(plot); - scaleAutoAction->setEnabled(plot); - zoomInAction->setEnabled(plot); - zoomOutAction->setEnabled(plot); - zoomInXAction->setEnabled(plot); - zoomOutXAction->setEnabled(plot); - zoomInYAction->setEnabled(plot); - zoomOutYAction->setEnabled(plot); - shiftLeftXAction->setEnabled(plot); - shiftRightXAction->setEnabled(plot); - shiftUpYAction->setEnabled(plot); - shiftDownYAction->setEnabled(plot); + bool plot =3D false; + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + //check whether we have cartesian plots selected + foreach (QGraphicsItem* item , m_selectedItems) { + if (item->data(0).toInt() =3D=3D WorksheetElement::NameCartesi= anPlot) { + plot =3D true; + break; + } + } + } else { + //actions are applied to all available plots -> check whether we h= ave plots + plot =3D (m_worksheet->children().size() !=3D 0); + } + + cartesianPlotSelectionModeAction->setEnabled(plot); + cartesianPlotZoomSelectionModeAction->setEnabled(plot); + cartesianPlotZoomXSelectionModeAction->setEnabled(plot); + cartesianPlotZoomYSelectionModeAction->setEnabled(plot); + + addCurveAction->setEnabled(plot); + addEquationCurveAction->setEnabled(plot); + addFitCurveAction->setEnabled(plot); + addHorizontalAxisAction->setEnabled(plot); + addVerticalAxisAction->setEnabled(plot); + addLegendAction->setEnabled(plot); + + scaleAutoXAction->setEnabled(plot); + scaleAutoYAction->setEnabled(plot); + scaleAutoAction->setEnabled(plot); + zoomInAction->setEnabled(plot); + zoomOutAction->setEnabled(plot); + zoomInXAction->setEnabled(plot); + zoomOutXAction->setEnabled(plot); + zoomInYAction->setEnabled(plot); + zoomOutYAction->setEnabled(plot); + shiftLeftXAction->setEnabled(plot); + shiftRightXAction->setEnabled(plot); + shiftUpYAction->setEnabled(plot); + shiftDownYAction->setEnabled(plot); } = void WorksheetView::exportToFile(const QString& path, const ExportFormat f= ormat, - const ExportArea area, const bool background, const int resolutio= n) { - QRectF sourceRect; - - //determine the rectangular to print - if (area=3D=3DWorksheetView::ExportBoundingBox){ - sourceRect =3D scene()->itemsBoundingRect(); - }else if (area=3D=3DWorksheetView::ExportSelection){ - //TODO doesn't work: rect =3D scene()->selectionArea().boundingRect(); - foreach(QGraphicsItem* item, m_selectedItems) { - sourceRect =3D sourceRect.united( item->mapToScene(item->boundingRect()= ).boundingRect() ); - } - }else{ - sourceRect =3D scene()->sceneRect(); - } - - //print - if (format=3D=3DWorksheetView::Pdf || format=3D=3DWorksheetView::Eps){ - QPrinter printer(QPrinter::HighResolution); - if (format=3D=3DWorksheetView::Pdf) - printer.setOutputFormat(QPrinter::PdfFormat); - else - printer.setOutputFormat(QPrinter::PostScriptFormat); - - printer.setOutputFileName(path); - int w =3D Worksheet::convertFromSceneUnits(sourceRect.width(), Worksheet= ::Millimeter); - int h =3D Worksheet::convertFromSceneUnits(sourceRect.height(), Workshee= t::Millimeter); - printer.setPaperSize( QSizeF(w, h), QPrinter::Millimeter); - printer.setPageMargins(0,0,0,0, QPrinter::Millimeter); - printer.setPrintRange(QPrinter::PageRange); - printer.setCreator( QString("LabPlot ") + LVERSION ); - - QPainter painter(&printer); - painter.setRenderHint(QPainter::Antialiasing); - QRectF targetRect(0, 0, painter.device()->width(),painter.device()->heig= ht()); - painter.begin(&printer); - exportPaint(&painter, targetRect, sourceRect, background); - painter.end(); - }else if (format=3D=3DWorksheetView::Svg){ - QSvgGenerator generator; - generator.setFileName(path); - int w =3D Worksheet::convertFromSceneUnits(sourceRect.width(), Worksheet= ::Millimeter); - int h =3D Worksheet::convertFromSceneUnits(sourceRect.height(), Workshee= t::Millimeter); - w =3D w*QApplication::desktop()->physicalDpiX()/25.4; - h =3D h*QApplication::desktop()->physicalDpiY()/25.4; - - generator.setSize(QSize(w, h)); - QRectF targetRect(0, 0, w, h); - generator.setViewBox(targetRect); - - QPainter painter; - painter.begin(&generator); - exportPaint(&painter, targetRect, sourceRect, background); - painter.end(); - }else{ - //PNG - //TODO add all formats supported by Qt in QImage - int w =3D Worksheet::convertFromSceneUnits(sourceRect.width(), Worksheet= ::Millimeter); - int h =3D Worksheet::convertFromSceneUnits(sourceRect.height(), Workshee= t::Millimeter); - w =3D w*resolution/25.4; - h =3D h*resolution/25.4; - QImage image(QSize(w, h), QImage::Format_ARGB32_Premultiplied); - image.fill(Qt::transparent); - QRectF targetRect(0, 0, w, h); - - QPainter painter; - painter.begin(&image); - painter.setRenderHint(QPainter::Antialiasing); - exportPaint(&painter, targetRect, sourceRect, background); - painter.end(); - - image.save(path, "png"); - } + const ExportArea area, const bool backgro= und, const int resolution) { + QRectF sourceRect; + + //determine the rectangular to print + if (area=3D=3DWorksheetView::ExportBoundingBox){ + sourceRect =3D scene()->itemsBoundingRect(); + }else if (area=3D=3DWorksheetView::ExportSelection){ + //TODO doesn't work: rect =3D scene()->selectionArea().boundingRec= t(); + foreach(QGraphicsItem* item, m_selectedItems) { + sourceRect =3D sourceRect.united( item->mapToScene(item->bound= ingRect()).boundingRect() ); + } + }else{ + sourceRect =3D scene()->sceneRect(); + } + + //print + if (format=3D=3DWorksheetView::Pdf || format=3D=3DWorksheetView::Eps){ + QPrinter printer(QPrinter::HighResolution); + if (format=3D=3DWorksheetView::Pdf) + printer.setOutputFormat(QPrinter::PdfFormat); + else +// printer.setOutputFormat(QPrinter::PostScriptFormat); + + printer.setOutputFileName(path); + int w =3D Worksheet::convertFromSceneUnits(sourceRect.width(), Wor= ksheet::Millimeter); + int h =3D Worksheet::convertFromSceneUnits(sourceRect.height(), Wo= rksheet::Millimeter); + printer.setPaperSize( QSizeF(w, h), QPrinter::Millimeter); + printer.setPageMargins(0,0,0,0, QPrinter::Millimeter); + printer.setPrintRange(QPrinter::PageRange); + printer.setCreator( QString("LabPlot ") + LVERSION ); + + QPainter painter(&printer); + painter.setRenderHint(QPainter::Antialiasing); + QRectF targetRect(0, 0, painter.device()->width(),painter.device()= ->height()); + painter.begin(&printer); + exportPaint(&painter, targetRect, sourceRect, background); + painter.end(); + }else if (format=3D=3DWorksheetView::Svg){ + QSvgGenerator generator; + generator.setFileName(path); + int w =3D Worksheet::convertFromSceneUnits(sourceRect.width(), Wor= ksheet::Millimeter); + int h =3D Worksheet::convertFromSceneUnits(sourceRect.height(), Wo= rksheet::Millimeter); + w =3D w*QApplication::desktop()->physicalDpiX()/25.4; + h =3D h*QApplication::desktop()->physicalDpiY()/25.4; + + generator.setSize(QSize(w, h)); + QRectF targetRect(0, 0, w, h); + generator.setViewBox(targetRect); + + QPainter painter; + painter.begin(&generator); + exportPaint(&painter, targetRect, sourceRect, background); + painter.end(); + }else{ + //PNG + //TODO add all formats supported by Qt in QImage + int w =3D Worksheet::convertFromSceneUnits(sourceRect.width(), Wor= ksheet::Millimeter); + int h =3D Worksheet::convertFromSceneUnits(sourceRect.height(), Wo= rksheet::Millimeter); + w =3D w*resolution/25.4; + h =3D h*resolution/25.4; + QImage image(QSize(w, h), QImage::Format_ARGB32_Premultiplied); + image.fill(Qt::transparent); + QRectF targetRect(0, 0, w, h); + + QPainter painter; + painter.begin(&image); + painter.setRenderHint(QPainter::Antialiasing); + exportPaint(&painter, targetRect, sourceRect, background); + painter.end(); + + image.save(path, "png"); + } } = void WorksheetView::exportPaint(QPainter* painter, const QRectF& targetRec= t, const QRectF& sourceRect, const bool background) { - //draw the background - if (background) { - painter->save(); - painter->scale(targetRect.width()/sourceRect.width(), targetRect.height(= )/sourceRect.height()); - drawBackground(painter, sourceRect); - painter->restore(); - } - - //draw the scene items - m_worksheet->setPrinting(true); - scene()->render(painter, QRectF(), sourceRect); - m_worksheet->setPrinting(false); + //draw the background + if (background) { + painter->save(); + painter->scale(targetRect.width()/sourceRect.width(), targetRect.h= eight()/sourceRect.height()); + drawBackground(painter, sourceRect); + painter->restore(); + } + + //draw the scene items + m_worksheet->setPrinting(true); + scene()->render(painter, QRectF(), sourceRect); + m_worksheet->setPrinting(false); } = void WorksheetView::print(QPrinter* printer) const{ - m_worksheet->setPrinting(true); - QPainter painter(printer); - painter.setRenderHint(QPainter::Antialiasing); - scene()->render(&painter); - m_worksheet->setPrinting(false); + m_worksheet->setPrinting(true); + QPainter painter(printer); + painter.setRenderHint(QPainter::Antialiasing); + scene()->render(&painter); + m_worksheet->setPrinting(false); } = void WorksheetView::updateBackground(){ - invalidateScene(sceneRect(), QGraphicsScene::BackgroundLayer); + invalidateScene(sceneRect(), QGraphicsScene::BackgroundLayer); } = /*! @@ -1289,30 +1289,30 @@ void WorksheetView::updateBackground(){ * enables the corresponding action */ void WorksheetView::layoutChanged(Worksheet::Layout layout) { - if (layout=3D=3DWorksheet::NoLayout){ - verticalLayoutAction->setEnabled(true); - verticalLayoutAction->setChecked(false); - - horizontalLayoutAction->setEnabled(true); - horizontalLayoutAction->setChecked(false); - - gridLayoutAction->setEnabled(true); - gridLayoutAction->setChecked(false); - - breakLayoutAction->setEnabled(false); - }else{ - verticalLayoutAction->setEnabled(false); - horizontalLayoutAction->setEnabled(false); - gridLayoutAction->setEnabled(false); - breakLayoutAction->setEnabled(true); - - if (layout=3D=3DWorksheet::VerticalLayout) - verticalLayoutAction->setChecked(true); - else if (layout=3D=3DWorksheet::HorizontalLayout) - horizontalLayoutAction->setChecked(true); - else - gridLayoutAction->setChecked(true); - } + if (layout=3D=3DWorksheet::NoLayout){ + verticalLayoutAction->setEnabled(true); + verticalLayoutAction->setChecked(false); + + horizontalLayoutAction->setEnabled(true); + horizontalLayoutAction->setChecked(false); + + gridLayoutAction->setEnabled(true); + gridLayoutAction->setChecked(false); + + breakLayoutAction->setEnabled(false); + }else{ + verticalLayoutAction->setEnabled(false); + horizontalLayoutAction->setEnabled(false); + gridLayoutAction->setEnabled(false); + breakLayoutAction->setEnabled(true); + + if (layout=3D=3DWorksheet::VerticalLayout) + verticalLayoutAction->setChecked(true); + else if (layout=3D=3DWorksheet::HorizontalLayout) + horizontalLayoutAction->setChecked(true); + else + gridLayoutAction->setChecked(true); + } } = = @@ -1320,273 +1320,273 @@ void WorksheetView::layoutChanged(Worksheet::Layo= ut layout) { //######################## SLOTs for cartesian plots ##################= ###### //########################################################################= ###### void WorksheetView::cartesianPlotActionModeChanged(QAction* action) { - if (action =3D=3D cartesianPlotApplyToSelectionAction) - m_cartesianPlotActionMode =3D ApplyActionToSelection; - else - m_cartesianPlotActionMode =3D ApplyActionToAll; + if (action =3D=3D cartesianPlotApplyToSelectionAction) + m_cartesianPlotActionMode =3D ApplyActionToSelection; + else + m_cartesianPlotActionMode =3D ApplyActionToAll; = - handleCartesianPlotActions(); + handleCartesianPlotActions(); } = void WorksheetView::cartesianPlotMouseModeChanged(QAction* action) { - if (action=3D=3DcartesianPlotSelectionModeAction) { - m_cartesianPlotMouseMode =3D CartesianPlot::SelectionMode; - } else if (action=3D=3DcartesianPlotZoomSelectionModeAction) { - m_cartesianPlotMouseMode =3D CartesianPlot::ZoomSelectionMode; - } else if (action=3D=3DcartesianPlotZoomXSelectionModeAction) { - m_cartesianPlotMouseMode =3D CartesianPlot::ZoomXSelectionMode; - } else if (action=3D=3DcartesianPlotZoomYSelectionModeAction) { - m_cartesianPlotMouseMode =3D CartesianPlot::ZoomYSelectionMode; - } - - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->setMouseMode(m_cartesianPlotMouseMode); - } + if (action=3D=3DcartesianPlotSelectionModeAction) { + m_cartesianPlotMouseMode =3D CartesianPlot::SelectionMode; + } else if (action=3D=3DcartesianPlotZoomSelectionModeAction) { + m_cartesianPlotMouseMode =3D CartesianPlot::ZoomSelectionMode; + } else if (action=3D=3DcartesianPlotZoomXSelectionModeAction) { + m_cartesianPlotMouseMode =3D CartesianPlot::ZoomXSelectionMode; + } else if (action=3D=3DcartesianPlotZoomYSelectionModeAction) { + m_cartesianPlotMouseMode =3D CartesianPlot::ZoomYSelectionMode; + } + + foreach(CartesianPlot* plot, m_worksheet->children() ){ + plot->setMouseMode(m_cartesianPlotMouseMode); + } } = void WorksheetView::addCurve() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->addCurve(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->addCurve(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->addCurve(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->addCurve(); + } + } } = void WorksheetView::addEquationCurve() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->addEquationCurve(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->addEquationCurve(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->addEquationCurve(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->addEquationCurve(); + } + } } = void WorksheetView::addFitCurve() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->addFitCurve(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->addFitCurve(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->addFitCurve(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->addFitCurve(); + } + } } = void WorksheetView::addLegend() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->addLegend(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->addLegend(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->addLegend(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->addLegend(); + } + } } = void WorksheetView::addHorizontalAxis() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->addHorizontalAxis(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->addHorizontalAxis(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->addHorizontalAxis(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->addHorizontalAxis(); + } + } } = void WorksheetView::addVerticalAxis() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->addVerticalAxis(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->addVerticalAxis(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->addVerticalAxis(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->addVerticalAxis(); + } + } } = void WorksheetView::scaleAuto() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->scaleAuto(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->scaleAuto(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->scaleAuto(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->scaleAuto(); + } + } } = void WorksheetView::scaleAutoX() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->scaleAutoX(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->scaleAutoX(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->scaleAutoX(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->scaleAutoX(); + } + } } = void WorksheetView::scaleAutoY() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->scaleAutoY(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->scaleAutoY(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->scaleAutoY(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->scaleAutoY(); + } + } } = void WorksheetView::zoomIn() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->zoomIn(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->zoomIn(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->zoomIn(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->zoomIn(); + } + } } = void WorksheetView::zoomOut() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->zoomOut(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->zoomOut(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->zoomOut(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->zoomOut(); + } + } } = void WorksheetView::zoomInX() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->zoomInX(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->zoomInX(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->zoomInX(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->zoomInX(); + } + } } = void WorksheetView::zoomOutX() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->zoomOutX(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->zoomOutX(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->zoomOutX(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->zoomOutX(); + } + } } = void WorksheetView::zoomInY() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->zoomInY(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->zoomInY(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->zoomInY(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->zoomInY(); + } + } } = void WorksheetView::zoomOutY() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->zoomOutY(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->zoomOutY(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->zoomOutY(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->zoomOutY(); + } + } } = void WorksheetView::shiftLeftX() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->shiftLeftX(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->shiftLeftX(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->shiftLeftX(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->shiftLeftX(); + } + } } = void WorksheetView::shiftRightX() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->shiftRightX(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->shiftRightX(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->shiftRightX(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->shiftRightX(); + } + } } = void WorksheetView::shiftUpY() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->shiftUpY(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->shiftUpY(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->shiftUpY(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->shiftUpY(); + } + } } = void WorksheetView::shiftDownY() { - if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) - plot->shiftDownY(); - } - } else { - foreach(CartesianPlot* plot, m_worksheet->children() ){ - plot->shiftDownY(); - } - } + if (m_cartesianPlotActionMode =3D=3D ApplyActionToSelection) { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + if (m_selectedItems.indexOf(plot->graphicsItem())!=3D-1) + plot->shiftDownY(); + } + } else { + foreach(CartesianPlot* plot, m_worksheet->children(= ) ){ + plot->shiftDownY(); + } + } } diff --git a/src/kdefrontend/GuiObserver.cpp b/src/kdefrontend/GuiObserver.= cpp index 8457e71..f0572e8 100644 --- a/src/kdefrontend/GuiObserver.cpp +++ b/src/kdefrontend/GuiObserver.cpp @@ -58,7 +58,7 @@ Email (use @ for *) : alexander.semke*web.de #include #include #include -#include +#include #include = /*! diff --git a/src/kdefrontend/MainWin.cpp b/src/kdefrontend/MainWin.cpp index 0acb89b..38ba9d0 100644 --- a/src/kdefrontend/MainWin.cpp +++ b/src/kdefrontend/MainWin.cpp @@ -58,9 +58,10 @@ #include #include #include +#include #include +#include = -#include #include #include #include @@ -68,8 +69,7 @@ #include #include #include -#include -#include +#include #include = /*! @@ -111,7 +111,7 @@ MainWin::MainWin(QWidget *parent, const QString& filena= me) } = MainWin::~MainWin() { - kDebug()<<"write settings"<saveEntries( KSharedConfig::openConfig()->grou= p("Recent Files") ); @@ -701,7 +701,7 @@ bool MainWin::openXML(QIODevice *file) { XmlStreamReader reader(file); if (m_project->load(&reader) =3D=3D false) { RESET_CURSOR; - kDebug()<<"ERROR: reading file content"<showMessage(msg_text); @@ -1337,7 +1337,7 @@ void MainWin::newFileDataSourceActionTriggered(){ FileDataSource* dataSource =3D new FileDataSource(0, i18n("File dat= a source%1", 1)); dlg->importToFileDataSource(dataSource, statusBar()); this->addAspectToProject(dataSource); - kDebug()<<"new file data source created"< #include #include -#include #include +#include #include +#include = /** * \brief Settings dialog for Labplot. diff --git a/src/kdefrontend/SettingsGeneralPage.cpp b/src/kdefrontend/Sett= ingsGeneralPage.cpp index e3ce1ea..18267f5 100644 --- a/src/kdefrontend/SettingsGeneralPage.cpp +++ b/src/kdefrontend/SettingsGeneralPage.cpp @@ -29,8 +29,9 @@ #include "SettingsGeneralPage.h" #include "MainWin.h" = -#include -#include +#include +#include +#include #include = /** diff --git a/src/kdefrontend/TemplateHandler.cpp b/src/kdefrontend/Template= Handler.cpp index 1aae237..45db522 100644 --- a/src/kdefrontend/TemplateHandler.cpp +++ b/src/kdefrontend/TemplateHandler.cpp @@ -34,10 +34,9 @@ #include #include #include -#include -#include + +#include #include -#include #include #include /*! diff --git a/src/tools/TeXRenderer.cpp b/src/tools/TeXRenderer.cpp index c909ca0..c00f2a8 100644 --- a/src/tools/TeXRenderer.cpp +++ b/src/tools/TeXRenderer.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include = // use (pdf)latex to render LaTeX text (see tex2im, etc.) // TODO: test convert to svg and render to qimage, test dvipng