diff --git a/kspread/Makefile.am b/kspread/Makefile.am
index 865e507f7d..99fc9c7859 100644
--- a/kspread/Makefile.am
+++ b/kspread/Makefile.am
@@ -1,98 +1,100 @@
INCLUDES = $(KOFFICE_INCLUDES) -I$(interfacedir) \
$(KOSCRIPT_INCLUDES) -I$(top_srcdir)/interfaces \
-I$(top_srcdir)/kchart/kdchart $(all_includes)
## The part
kde_module_LTLIBRARIES = libkspreadpart.la
libkspreadpart_la_SOURCES = kspread_locale.cc \
kspread_dlg_formula.cc \
kspread_functions.cc \
kspread_canvas.cc \
kspread_doc.cc \
kspread_undo.cc kspread_view.cc kspread_tabbar.cc \
kspread_autofill.cc kspread_interpreter.cc \
kspread_functions_math.cc kspread_functions_conversion.cc \
kspread_functions_logic.cc kspread_functions_financial.cc \
kspread_functions_trig.cc kspread_functions_datetime.cc \
kspread_functions_statistical.cc kspread_functions_text.cc \
kspread_layout.cc kspread_map.cc kspread_dlg_layout.cc \
kspread_dlg_scripts.cc kspread_cell.cc kspread_table.cc \
kspread_dlg_cons.cc kspread_util.cc \
+ kspread_dlg_database.cc \
kspread_editors.cc \
kspread_dlg_reference.cc\
kspread_dlg_comment.cc kspread_dlg_angle.cc kspread_dlg_goto.cc\
kspread_dlg_area.cc kspread_dlg_resize2.cc kspread_dlg_preference.cc\
kspread_dlg_special.cc \
kspread_dlg_sort.cc kspread_dlg_anchor.cc kspread_dlg_conditional.cc\
kspread_factory.cc kspread_handler.cc \
kspread_events.cc kspread_dlg_show.cc kspread_dlg_series.cc \
kspread_dlg_validity.cc kspread_dlg_showColRow.cc \
kspread_dlg_list.cc \
kspread_dlg_insert.cc kspread_dlg_pasteinsert.cc KSpreadDocIface.skel KSpreadMapIface.skel \
KSpreadTableIface.skel KSpreadDocIface.cc KSpreadMapIface.cc \
KSpreadTableIface.cc KSpreadCellIface.cc KSpreadCellIface.skel \
KSpreadAppIface.cc KSpreadAppIface.skel kspread_dlg_format.cc \
KSpreadViewIface.skel KSpreadViewIface.cc \
kspread_cluster.cc kspread_depend.cc kspread_condition.cc \
KSpreadLayoutIface.skel KSpreadLayoutIface.cc KSpreadColumnIface.skel KSpreadColumnIface.cc KSpreadRowIface.skel KSpreadRowIface.cc
libkspreadpart_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
libkspreadpart_la_LIBADD = $(top_builddir)/interfaces/libkochart.la \
$(LIB_KOSCRIPT) $(LIB_KOFFICEUI) -lkspell
libkspreadpart_la_METASOURCES = AUTO
## The kdeinit loadable module
lib_LTLIBRARIES = kspread.la
kspread_la_SOURCES = main.cc
kspread_la_LDFLAGS = $(all_libraries) -avoid-version -module
kspread_la_LIBADD = $(LIB_KOFFICECORE)
## The executable
bin_PROGRAMS = kspread
kspread_SOURCES = dummy.cc
kspread_LDFLAGS = $(all_libraries) $(KDE_RPATH)
kspread_LDADD = kspread.la
dummy.cc:
echo > dummy.cc
noinst_HEADERS = kspread_doc.h kspread_functions.h \
kspread_undo.h kspread_view.h kspread_tabbar.h \
kspread_autofill.h kspread_interpreter.h \
kspread_layout.h kspread_map.h kspread_dlg_layout.h \
kspread_dlg_scripts.h kspread_table.h kspread_cell.h \
kspread_dlg_cons.h kspread_cluster.h \
kspread_util.h kspread_canvas.h \
kspread_dlg_reference.h kspread_locale.h \
kspread_editors.h kspread_dlg_formula.h \
kspread_dlg_reference.h kspread_dlg_area.h kspread_dlg_resize2.h\
kspread_dlg_special.h kspread_dlg_goto.h \
kspread_dlg_sort.h kspread_dlg_anchor.h kspread_dlg_series.h \
kspread_dlg_preference.h kspread_dlg_angle.h \
kspread_factory.h kspread_handler.h \
kspread_dlg_validity.h kspread_dlg_showColRow.h \
kspread_dlg_list.h \
+ kspread_dlg_database.h \
kspread_events.h kspread_global.h \
kspread_dlg_show.h kspread_dlg_insert.h kspread_dlg_pasteinsert.h KSpreadViewIface.h \
KSpreadCellIface.h KSpreadMapIface.h KSpreadTableIface.h KSpreadDocIface.h \
KSpreadAppIface.h kspread_dlg_format.h kspread_aboutdata.h \
kspread_depend.h kspread_condition.h KSpreadLayoutIface.h KSpreadColumnIface.h KSpreadRowIface.h
kdelnk_DATA = kspread.desktop
kdelnkdir = $(kde_appsdir)/Office
rcdir = $(kde_datadir)/kspread
rc_DATA = kspread.rc
SUBDIRS = . plugins pics dtd toolbar extensions tablestyles
parser:
flex lex.l
yacc -d yacc.y
flex -Pdep lex.dep.l
bison -p dep -b dep -d yacc.dep.y
messages: rc.cpp
perl extracti18n extensions/*.xml > xml_doc.cc
$(XGETTEXT) rc.cpp *.cc kspread_aboutdata.h -o $(podir)/kspread.pot
-rm xml_doc.cc
diff --git a/kspread/kspread.rc b/kspread/kspread.rc
index 11b2f74e05..d78351560a 100644
--- a/kspread/kspread.rc
+++ b/kspread/kspread.rc
@@ -1,198 +1,205 @@
&View
&Insert
Commen&t
+
+
+ &External data
+
+
+
+
F&ormat
&Row
&Column
&Data
Ta&ble
&Tools
&Settings
Edit
Math
Format
Color/Border
diff --git a/kspread/kspread_dlg_database.cc b/kspread/kspread_dlg_database.cc
new file mode 100644
index 0000000000..29ba0eda4e
--- /dev/null
+++ b/kspread/kspread_dlg_database.cc
@@ -0,0 +1,1168 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Norbert Andres, nandres@web.de
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "kspread_cell.h"
+#include "kspread_dlg_database.h"
+#include "kspread_doc.h"
+#include "kspread_table.h"
+#include "kspread_util.h"
+#include "kspread_undo.h"
+#include "kspread_view.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+class KSpreadUndoInsertData : public KSpreadUndoChangeAreaTextCell
+{
+ public:
+ KSpreadUndoInsertData( KSpreadDoc * _doc, KSpreadTable * _table, QRect & _selection )
+ : KSpreadUndoChangeAreaTextCell( _doc, _table, _selection )
+ {
+ name = i18n("Insert data from database");
+ }
+};
+
+/********************************************************
+ * Database wizard *
+ ********************************************************/
+
+KSpreadDatabaseDlg::KSpreadDatabaseDlg( KSpreadView * parent, QRect const & rect, const char * name, bool modal, WFlags fl )
+ : KWizard( (QWidget *) parent, name, modal, fl ),
+ m_currentPage( eDatabase ),
+ m_pView( parent ),
+ m_targetRect( rect ),
+ m_dbConnection( 0L )
+{
+ if ( !name )
+ setName( "KSpreadDatabaseDlg" );
+
+ resize( 590, 480 );
+ setCaption( i18n( "Insert data from database" ) );
+
+ // database page
+
+ m_database = new QWidget( this, "m_database" );
+ m_databaseLayout = new QGridLayout( m_database, 1, 1, -1, -1, "m_databaseLayout");
+
+ QFrame * Frame5 = new QFrame( m_database, "Frame5" );
+ Frame5->setFrameShape( QFrame::MShape );
+ Frame5->setFrameShadow( QFrame::MShadow );
+ QVBoxLayout * Frame5Layout = new QVBoxLayout( Frame5, 11, 6, "Frame5Layout");
+
+
+ QFrame * Frame16 = new QFrame( Frame5, "Frame16" );
+ Frame16->setFrameShape( QFrame::NoFrame );
+ Frame16->setFrameShadow( QFrame::Plain );
+ QGridLayout * Frame16Layout = new QGridLayout( Frame16, 1, 1, 11, 7, "Frame16Layout");
+
+ m_Type = new QLabel( Frame16, "m_Type" );
+ m_Type->setText( i18n( "Type:" ) );
+
+ Frame16Layout->addWidget( m_Type, 0, 0 );
+
+ QLabel * TextLabel4 = new QLabel( Frame16, "TextLabel4" );
+ TextLabel4->setText( i18n( "Username:\n"
+ "(if necessary)" ) );
+ Frame16Layout->addWidget( TextLabel4, 4, 0 );
+
+ QLabel * TextLabel2 = new QLabel( Frame16, "TextLabel2" );
+ TextLabel2->setText( i18n( "Host:" ) );
+ Frame16Layout->addWidget( TextLabel2, 2, 0 );
+
+ m_driver = new QComboBox( FALSE, Frame16, "m_driver" );
+ Frame16Layout->addWidget( m_driver, 0, 1 );
+
+ m_username = new QLineEdit( Frame16, "m_username" );
+ Frame16Layout->addWidget( m_username, 4, 1 );
+
+ m_host = new QLineEdit( Frame16, "m_host" );
+ m_host->setText("localhost");
+ Frame16Layout->addWidget( m_host, 2, 1 );
+
+ QLabel * TextLabel3 = new QLabel( Frame16, "TextLabel3" );
+ TextLabel3->setText( i18n( "Port:\n(if necessary)") );
+ Frame16Layout->addWidget( TextLabel3, 3, 0 );
+
+ m_password = new QLineEdit( Frame16, "m_password" );
+ m_password->setEchoMode( QLineEdit::Password );
+ Frame16Layout->addWidget( m_password, 5, 1 );
+
+ m_port = new QLineEdit( Frame16, "m_port" );
+ m_port->setValidator( new KIntValidator( m_port ) );
+ Frame16Layout->addWidget( m_port, 3, 1 );
+
+ QLabel * dbName = new QLabel( Frame16, "dbName" );
+ dbName->setText( i18n( "Database name: ") );
+ Frame16Layout->addWidget( dbName, 1, 0 );
+
+ m_databaseName = new QLineEdit( Frame16, "m_databaseName" );
+ Frame16Layout->addWidget( m_databaseName, 1, 1 );
+
+ QLabel * TextLabel5 = new QLabel( Frame16, "TextLabel5" );
+ TextLabel5->setText( i18n( "Password:\n"
+ "(if necessary)" ) );
+ Frame16Layout->addWidget( TextLabel5, 5, 0 );
+ Frame5Layout->addWidget( Frame16 );
+
+ m_databaseStatus = new QLabel( Frame5, "m_databaseStatus" );
+ m_databaseStatus->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)5, 0, 0, m_databaseStatus->sizePolicy().hasHeightForWidth() ) );
+ m_databaseStatus->setMaximumSize( QSize( 32767, 30 ) );
+ m_databaseStatus->setText( " " );
+ Frame5Layout->addWidget( m_databaseStatus );
+
+ m_databaseLayout->addWidget( Frame5, 0, 1 );
+
+ QFrame * Frame17 = new QFrame( m_database, "Frame17" );
+ Frame17->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, Frame17->sizePolicy().hasHeightForWidth() ) );
+ Frame17->setMinimumSize( QSize( 111, 0 ) );
+ Frame17->setFrameShape( QFrame::NoFrame );
+ Frame17->setFrameShadow( QFrame::Plain );
+
+ m_databaseLayout->addWidget( Frame17, 0, 0 );
+ addPage( m_database, i18n( "Database" ) );
+
+ // new page
+
+ m_table = new QWidget( this, "m_table" );
+ m_tableLayout = new QGridLayout( m_table, 1, 1, 11, 6, "m_tableLayout");
+
+ QFrame * Frame5_2 = new QFrame( m_table, "Frame5_2" );
+ Frame5_2->setFrameShape( QFrame::MShape );
+ Frame5_2->setFrameShadow( QFrame::MShadow );
+ QGridLayout * Frame5_2Layout = new QGridLayout( Frame5_2, 1, 1, 11, 6, "Frame5_2Layout");
+
+ QHBoxLayout * Layout21 = new QHBoxLayout( 0, 0, 6, "Layout21");
+
+ // QLabel * TextLabel12_2 = new QLabel( Frame5_2, "TextLabel12_2" );
+ // TextLabel12_2->setText( i18n( "Database:" ) );
+ // Layout21->addWidget( TextLabel12_2 );
+
+ // m_databaseList = new QComboBox( FALSE, Frame5_2, "m_databaseList" );
+ // Layout21->addWidget( m_databaseList );
+
+ // m_connectButton = new KPushButton( Frame5_2, "m_connectButton" );
+ // m_connectButton->setText( i18n( "&Connect" ) );
+ // Layout21->addWidget( m_connectButton );
+
+ Frame5_2Layout->addLayout( Layout21, 0, 0 );
+
+ m_tableStatus = new QLabel( Frame5_2, "m_tableStatus" );
+ m_tableStatus->setText( " " );
+ Frame5_2Layout->addWidget( m_tableStatus, 3, 0 );
+
+ m_SelectTableLabel = new QLabel( Frame5_2, "m_SelectTableLabel" );
+ m_SelectTableLabel->setText( i18n( "Select table(s):" ) );
+ Frame5_2Layout->addWidget( m_SelectTableLabel, 1, 0 );
+
+ m_tableView = new KListView( Frame5_2, "m_tableView" );
+ m_tableView->addColumn( i18n( "Table" ) );
+ m_tableView->setRootIsDecorated( FALSE );
+
+ Frame5_2Layout->addWidget( m_tableView, 2, 0 );
+
+ m_tableLayout->addWidget( Frame5_2, 0, 1 );
+
+ QFrame * Frame17_2 = new QFrame( m_table, "Frame17_2" );
+ Frame17_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, Frame17_2->sizePolicy().hasHeightForWidth() ) );
+ Frame17_2->setMinimumSize( QSize( 111, 0 ) );
+ Frame17_2->setFrameShape( QFrame::NoFrame );
+ Frame17_2->setFrameShadow( QFrame::Plain );
+
+ m_tableLayout->addWidget( Frame17_2, 0, 0 );
+ addPage( m_table, i18n( "Tables" ) );
+
+ m_columns = new QWidget( this, "m_columns" );
+ m_columnsLayout = new QGridLayout( m_columns, 1, 1, 11, 6, "m_columnsLayout");
+
+ QFrame * Frame5_2_2 = new QFrame( m_columns, "Frame5_2_2" );
+ Frame5_2_2->setFrameShape( QFrame::MShape );
+ Frame5_2_2->setFrameShadow( QFrame::MShadow );
+ QGridLayout * Frame5_2_2Layout = new QGridLayout( Frame5_2_2, 1, 1, 11, 6, "Frame5_2_2Layout");
+
+ QLabel * TextLabel11_2 = new QLabel( Frame5_2_2, "TextLabel11_2" );
+ TextLabel11_2->setText( i18n( "Select columns(s):" ) );
+
+ Frame5_2_2Layout->addWidget( TextLabel11_2, 0, 0 );
+
+ m_columnView = new KListView( Frame5_2_2, "m_columnView" );
+ m_columnView->addColumn( i18n( "Column" ) );
+ m_columnView->addColumn( i18n( "Table" ) );
+ m_columnView->addColumn( i18n( "Data type" ) );
+ m_columnView->setRootIsDecorated( FALSE );
+
+ Frame5_2_2Layout->addWidget( m_columnView, 1, 0 );
+
+ m_columnsStatus = new QLabel( Frame5_2_2, "m_columnsStatus" );
+ m_columnsStatus->setText( " " );
+ Frame5_2_2Layout->addWidget( m_columnsStatus, 2, 0 );
+
+ m_columnsLayout->addWidget( Frame5_2_2, 0, 1 );
+
+ QFrame * Frame17_3 = new QFrame( m_columns, "Frame17_3" );
+ Frame17_3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, Frame17_3->sizePolicy().hasHeightForWidth() ) );
+ Frame17_3->setMinimumSize( QSize( 111, 0 ) );
+ Frame17_3->setFrameShape( QFrame::NoFrame );
+ Frame17_3->setFrameShadow( QFrame::Plain );
+
+ m_columnsLayout->addWidget( Frame17_3, 0, 0 );
+ addPage( m_columns, i18n( "Columns" ) );
+
+ // options page
+
+ m_options = new QWidget( this, "m_options" );
+ m_optionsLayout = new QGridLayout( m_options, 1, 1, 11, 6, "m_optionsLayout");
+
+ QFrame * optionsFrame = new QFrame( m_options, "optionsFrame" );
+ optionsFrame->setFrameShape( QFrame::MShape );
+ optionsFrame->setFrameShadow( QFrame::MShadow );
+ QGridLayout * optionsFrameLayout = new QGridLayout( optionsFrame, 1, 1, 11, 6, "optionsFrameLayout");
+
+ m_columns_1 = new QComboBox( false, optionsFrame, "m_columns_1" );
+ optionsFrameLayout->addWidget( m_columns_1, 2, 0 );
+
+ m_operatorValue_2 = new QLineEdit( optionsFrame, "m_operatorValue_2" );
+ optionsFrameLayout->addWidget( m_operatorValue_2, 3, 2 );
+
+ m_andBox = new QRadioButton( optionsFrame, "m_andBox" );
+ m_andBox->setText( i18n( "Match all of the following (AND)" ) );
+ m_andBox->setChecked( true );
+
+ optionsFrameLayout->addMultiCellWidget( m_andBox, 0, 0, 0, 2 );
+
+ m_orBox = new QRadioButton( optionsFrame, "m_orBox" );
+ m_orBox->setText( i18n( "Match any of the following (OR)" ) );
+ optionsFrameLayout->addMultiCellWidget( m_orBox, 1, 1, 0, 2 );
+
+ m_operatorValue_1 = new QLineEdit( optionsFrame, "m_operatorValue" );
+ optionsFrameLayout->addWidget( m_operatorValue_1, 2, 2 );
+
+ m_columns_2 = new QComboBox( FALSE, optionsFrame, "m_columns_2" );
+ optionsFrameLayout->addWidget( m_columns_2, 3, 0 );
+
+ m_operatorValue_3 = new QLineEdit( optionsFrame, "m_operatorValue_3" );
+ optionsFrameLayout->addWidget( m_operatorValue_3, 4, 2 );
+
+ m_operator_1 = new QComboBox( FALSE, optionsFrame, "m_operator_1" );
+ m_operator_1->insertItem( i18n( "equals" ) );
+ m_operator_1->insertItem( i18n( "not equal" ) );
+ m_operator_1->insertItem( i18n( "in" ) );
+ m_operator_1->insertItem( i18n( "not in" ) );
+ m_operator_1->insertItem( i18n( "like" ) );
+ m_operator_1->insertItem( i18n( "greater" ) );
+ m_operator_1->insertItem( i18n( "lesser" ) );
+ m_operator_1->insertItem( i18n( "greater or equal" ) );
+ m_operator_1->insertItem( i18n( "less or equal" ) );
+
+ optionsFrameLayout->addWidget( m_operator_1, 2, 1 );
+
+ m_operator_2 = new QComboBox( FALSE, optionsFrame, "m_operator_2" );
+ m_operator_2->insertItem( i18n( "equals" ) );
+ m_operator_2->insertItem( i18n( "not equal" ) );
+ m_operator_2->insertItem( i18n( "in" ) );
+ m_operator_2->insertItem( i18n( "not in" ) );
+ m_operator_2->insertItem( i18n( "like" ) );
+ m_operator_2->insertItem( i18n( "greater" ) );
+ m_operator_2->insertItem( i18n( "lesser" ) );
+
+ optionsFrameLayout->addWidget( m_operator_2, 3, 1 );
+
+ m_operator_3 = new QComboBox( FALSE, optionsFrame, "m_operator_3" );
+ m_operator_3->insertItem( i18n( "equals" ) );
+ m_operator_3->insertItem( i18n( "not equal" ) );
+ m_operator_3->insertItem( i18n( "in" ) );
+ m_operator_3->insertItem( i18n( "not in" ) );
+ m_operator_3->insertItem( i18n( "like" ) );
+ m_operator_3->insertItem( i18n( "greater" ) );
+ m_operator_3->insertItem( i18n( "lesser" ) );
+
+ optionsFrameLayout->addWidget( m_operator_3, 4, 1 );
+
+ m_columns_3 = new QComboBox( false, optionsFrame, "m_columns_3" );
+
+ optionsFrameLayout->addWidget( m_columns_3, 4, 0 );
+
+ m_distinct = new QCheckBox( optionsFrame, "m_distinct" );
+ m_distinct->setText( i18n( "Distinct" ) );
+
+ optionsFrameLayout->addWidget( m_distinct, 7, 2 );
+
+ QLabel * TextLabel19 = new QLabel( optionsFrame, "TextLabel19" );
+ TextLabel19->setText( i18n( "Sorted by" ) );
+ optionsFrameLayout->addWidget( TextLabel19, 5, 0 );
+
+ m_columnsSort_1 = new QComboBox( false, optionsFrame, "m_columnsSort_1" );
+ optionsFrameLayout->addWidget( m_columnsSort_1, 5, 1 );
+
+ m_sortMode_1 = new QComboBox( false, optionsFrame, "m_sortMode_1" );
+ m_sortMode_1->insertItem( i18n( "Ascending" ) );
+ m_sortMode_1->insertItem( i18n( "Descending" ) );
+ optionsFrameLayout->addWidget( m_sortMode_1, 5, 2 );
+
+ QLabel * TextLabel19_2 = new QLabel( optionsFrame, "TextLabel19_2" );
+ TextLabel19_2->setText( i18n( "Sorted by" ) );
+ optionsFrameLayout->addWidget( TextLabel19_2, 6, 0 );
+
+ m_columnsSort_2 = new QComboBox( false, optionsFrame, "m_columnsSort_2" );
+ optionsFrameLayout->addWidget( m_columnsSort_2, 6, 1 );
+
+ m_sortMode_2 = new QComboBox( false, optionsFrame, "m_sortMode_2" );
+ m_sortMode_2->insertItem( i18n( "Ascending" ) );
+ m_sortMode_2->insertItem( i18n( "Descending" ) );
+
+ optionsFrameLayout->addWidget( m_sortMode_2, 6, 2 );
+ QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ optionsFrameLayout->addItem( spacer, 7, 1 );
+ QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ optionsFrameLayout->addItem( spacer_2, 7, 0 );
+
+ m_optionsLayout->addWidget( optionsFrame, 0, 1 );
+
+ QFrame * Frame17_4 = new QFrame( m_options, "Frame17_4" );
+ Frame17_4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, Frame17_4->sizePolicy().hasHeightForWidth() ) );
+ Frame17_4->setMinimumSize( QSize( 111, 0 ) );
+ Frame17_4->setFrameShape( QFrame::NoFrame );
+ Frame17_4->setFrameShadow( QFrame::Plain );
+
+ m_optionsLayout->addWidget( Frame17_4, 0, 0 );
+ addPage( m_options, i18n( "Query options" ) );
+
+ // result page
+
+ m_result = new QWidget( this, "m_result" );
+ m_resultLayout = new QGridLayout( m_result, 1, 1, 11, 6, "m_resultLayout");
+
+ QFrame * Frame5_2_2_3 = new QFrame( m_result, "Frame5_2_2_3" );
+ Frame5_2_2_3->setFrameShape( QFrame::MShape );
+ Frame5_2_2_3->setFrameShadow( QFrame::MShadow );
+ QGridLayout * Frame5_2_2_3Layout = new QGridLayout( Frame5_2_2_3, 1, 1, 11, 6, "Frame5_2_2_3Layout");
+
+ QLabel * TextLabel17 = new QLabel( Frame5_2_2_3, "TextLabel17" );
+ TextLabel17->setText( i18n( "SQL query:" ) );
+ Frame5_2_2_3Layout->addWidget( TextLabel17, 0, 0 );
+
+ m_sqlQuery = new QTextEdit( Frame5_2_2_3, "m_sqlQuery" );
+ Frame5_2_2_3Layout->addWidget( m_sqlQuery, 1, 0 );
+
+ QFrame * Frame12 = new QFrame( Frame5_2_2_3, "Frame12" );
+ Frame12->setFrameShape( QFrame::StyledPanel );
+ Frame12->setFrameShadow( QFrame::Raised );
+ QGridLayout * Frame12Layout = new QGridLayout( Frame12, 1, 1, 11, 6, "Frame12Layout");
+
+ m_startingRegion = new QRadioButton( Frame12, "m_startingRegion" );
+ m_startingRegion->setText( i18n( "Insert in region" ) );
+ Frame12Layout->addWidget( m_startingRegion, 0, 0 );
+
+ m_cell = new QLineEdit( Frame12, "m_cell" );
+ Frame12Layout->addWidget( m_cell, 1, 1 );
+
+ m_region = new QLineEdit( Frame12, "m_region" );
+ Frame12Layout->addWidget( m_region, 0, 1 );
+
+ m_startingCell = new QRadioButton( Frame12, "m_startingCell" );
+ m_startingCell->setText( i18n( "Starting in cell" ) );
+ m_startingCell->setChecked( TRUE );
+ Frame12Layout->addWidget( m_startingCell, 1, 0 );
+
+ Frame5_2_2_3Layout->addWidget( Frame12, 2, 0 );
+ m_resultLayout->addWidget( Frame5_2_2_3, 0, 1 );
+
+ QFrame * Frame17_5 = new QFrame( m_result, "Frame17_5" );
+ Frame17_5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, Frame17_5->sizePolicy().hasHeightForWidth() ) );
+ Frame17_5->setMinimumSize( QSize( 111, 0 ) );
+ Frame17_5->setFrameShape( QFrame::NoFrame );
+ Frame17_5->setFrameShadow( QFrame::Plain );
+
+ m_resultLayout->addWidget( Frame17_5, 0, 0 );
+ addPage( m_result, i18n( "Result" ) );
+
+ finishButton()->setEnabled(false);
+
+ // signals and slots connections
+ connect( m_orBox, SIGNAL( clicked() ), this, SLOT( orBox_clicked() ) );
+ connect( m_andBox, SIGNAL( clicked() ), this, SLOT( andBox_clicked() ) );
+ connect( m_startingCell, SIGNAL( clicked() ), this, SLOT( startingCell_clicked() ) );
+ connect( m_startingRegion, SIGNAL( clicked() ), this, SLOT( startingRegion_clicked() ) );
+ connect( m_driver, SIGNAL( activated(int) ), this, SLOT( databaseDriverChanged(int) ) );
+ connect( m_host, SIGNAL( textChanged(const QString &) ), this, SLOT( databaseHostChanged(const QString &) ) );
+ connect( m_databaseName, SIGNAL( textChanged(const QString &) ), this, SLOT( databaseNameChanged(const QString &) ) );
+ connect( m_tableView, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint &, int ) ),
+ this, SLOT( popupTableViewMenu(QListViewItem *, const QPoint &, int ) ) );
+ connect( m_tableView, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( tableViewClicked( QListViewItem * ) ) );
+
+ QStringList str = QSqlDatabase::drivers();
+ m_driver->insertItem("");
+ m_driver->insertStringList( str );
+ if ( str.isEmpty() )
+ {
+ KMessageBox::error( this, i18n("No database drivers available! You need "
+ "to compile QT with the necessary drivers.") );
+ }
+
+ helpButton()->hide();
+ setNextEnabled(m_database, false);
+ setNextEnabled(m_table, false);
+ setNextEnabled(m_columns, false);
+ setNextEnabled(m_options, false);
+ setNextEnabled(m_result, false);
+}
+
+KSpreadDatabaseDlg::~KSpreadDatabaseDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+ if ( m_dbConnection )
+ m_dbConnection->close();
+}
+
+void KSpreadDatabaseDlg::switchPage( int id )
+{
+ if ( id > eResult )
+ --m_currentPage;
+ if ( id < eDatabase )
+ ++m_currentPage;
+
+ switch ( id )
+ {
+ case eDatabase:
+ showPage(m_database);
+ break;
+
+ case eTables:
+ showPage(m_table);
+ break;
+
+ case eColumns:
+ showPage(m_columns);
+ break;
+
+ case eOptions:
+ showPage(m_options);
+ break;
+
+ case eResult:
+ showPage(m_result);
+ break;
+
+ default:
+ break;
+ }
+}
+
+void KSpreadDatabaseDlg::next()
+{
+ switch ( m_currentPage )
+ {
+ case eDatabase:
+ if (!databaseDoNext())
+ return;
+ break;
+
+ case eTables:
+ if (!tablesDoNext())
+ return;
+ break;
+
+ case eColumns:
+ if (!columnsDoNext())
+ return;
+ break;
+
+ case eOptions:
+ if (!optionsDoNext())
+ return;
+ break;
+
+ case eResult:
+ // there is nothing to do here
+ break;
+
+ default:
+ break;
+ }
+
+ ++m_currentPage;
+
+ switchPage( m_currentPage );
+}
+
+void KSpreadDatabaseDlg::back()
+{
+ --m_currentPage;
+
+ switchPage( m_currentPage );
+}
+
+void KSpreadDatabaseDlg::accept()
+{
+ KSpreadTable * table = m_pView->activeTable();
+ int top;
+ int left;
+ int width = -1;
+ int height = -1;
+ if ( m_startingRegion->isChecked() )
+ {
+ KSpreadRange range( m_region->text() );
+ if ( range.isTableKnown() )
+ {
+ KMessageBox::error( this, i18n("You cannot specify a table here!") );
+ m_region->setFocus();
+ m_region->selectAll();
+ return;
+ }
+
+ range.table = table;
+
+ if ( !range.isValid() )
+ {
+ KMessageBox::error( this, i18n("You have to specify a valid region!") );
+ m_region->setFocus();
+ m_region->selectAll();
+ return;
+ }
+ top = range.range.top();
+ left = range.range.left();
+ width = range.range.width();
+ height = range.range.height();
+ }
+ else
+ {
+ KSpreadPoint point( m_cell->text() );
+ if ( point.isTableKnown() )
+ {
+ KMessageBox::error( this, i18n("You cannot specify a table here!") );
+ m_cell->setFocus();
+ m_cell->selectAll();
+ return;
+ }
+ point.table = table;
+ // if ( point.pos.x() < 1 || point.pos.y() < 1 )
+ if ( !point.isValid() )
+ {
+ KMessageBox::error( this, i18n("You have to specify a valid cell!") );
+ m_cell->setFocus();
+ m_cell->selectAll();
+ return;
+ }
+ top = point.pos.y();
+ left = point.pos.x();
+ }
+
+ int i;
+ QString queryStr;
+ QString tmp = m_sqlQuery->text();
+ for ( i = 0; i < (int) tmp.length(); ++i )
+ {
+ if ( tmp[i] != '\n' )
+ queryStr += tmp[i];
+ else
+ queryStr += " ";
+ }
+
+ // if ( queryStr[queryStr.length() - 1] != ';' )
+ // queryStr += ";";
+
+ if ( ( queryStr.find("DELETE", 0, false) != -1 )
+ || ( queryStr.find("INSERT", 0, false) != -1 )
+ || ( queryStr.find("UPDATE", 0, false) != -1 ) )
+ {
+ KMessageBox::error( this, i18n("You are not allowed to change data in the database!") );
+ m_sqlQuery->setFocus();
+ return;
+ }
+
+ KSpreadCell * cell;
+ QSqlQuery query( QString::null, m_dbConnection );
+ if ( !query.exec( queryStr ) )
+ {
+ KMessageBox::error( this, i18n("Executing query failed!") );
+ m_sqlQuery->setFocus();
+ return;
+ }
+
+ int y = 0;
+ int count = m_columns_1->count();
+ if ( width != -1 )
+ {
+ if ( count > width )
+ count = width;
+ }
+
+ if ( height == -1 )
+ {
+ height = 0;
+ if ( query.first() )
+ {
+ if ( query.isValid() )
+ ++height;
+ }
+ while ( query.next() )
+ {
+ if ( query.isValid() )
+ ++height;
+ }
+ }
+
+ if ( !m_pView->doc()->undoBuffer()->isLocked() )
+ {
+ QRect r(left, top, count, height);
+ KSpreadUndoInsertData * undo = new KSpreadUndoInsertData( m_pView->doc(), table, r );
+ m_pView->doc()->undoBuffer()->appendUndo( undo );
+ }
+
+ if ( query.first() )
+ {
+ if ( query.isValid() )
+ {
+ for ( i = 0; i < count; ++i )
+ {
+ cell = table->nonDefaultCell( left + i, top + y );
+ cell->setCellText( query.value( i ).toString() );
+ }
+ ++y;
+ }
+ }
+
+ if ( y != height )
+ {
+ while ( query.next() )
+ {
+ if ( !query.isValid() )
+ continue;
+
+ for ( i = 0; i < count; ++i )
+ {
+ cell = table->nonDefaultCell( left + i, top + y );
+ cell->setCellText( query.value( i ).toString() );
+ }
+ ++y;
+
+ if ( y == height )
+ break;
+ }
+ }
+
+ KWizard::accept();
+}
+
+bool KSpreadDatabaseDlg::databaseDoNext()
+{
+ m_dbConnection = QSqlDatabase::addDatabase( m_driver->currentText() );
+
+ if ( m_dbConnection )
+ {
+ m_dbConnection->setDatabaseName( m_databaseName->text() );
+ m_dbConnection->setHostName( m_host->text() );
+
+ if ( !m_username->text().isEmpty() )
+ m_dbConnection->setUserName( m_username->text() );
+
+ if ( !m_password->text().isEmpty() )
+ m_dbConnection->setPassword( m_password->text() );
+
+ if ( !m_port->text().isEmpty() )
+ {
+ bool ok = false;
+ int port = m_port->text().toInt( &ok );
+ if (!ok)
+ {
+ KMessageBox::error( this, i18n("The port must be a number") );
+ return false;
+ }
+ m_dbConnection->setPort( port );
+ }
+
+ m_databaseStatus->setText( i18n("Connecting to database...") );
+ if ( m_dbConnection->open() )
+ {
+ m_databaseStatus->setText( i18n("Connected. Retrieving table information...") );
+ QStringList tableList( m_dbConnection->tables() );
+
+ if ( tableList.isEmpty() )
+ {
+ KMessageBox::error( this, i18n("This database contains no table") );
+ return false;
+ }
+
+ unsigned int i;
+ m_tableView->clear();
+
+ for ( i = 0; i < tableList.size(); ++i )
+ {
+ QCheckListItem * item = new QCheckListItem( m_tableView, tableList[i],
+ QCheckListItem::CheckBox );
+ item->setOn(false);
+ m_tableView->insertItem( item );
+ }
+
+ m_tableView->setEnabled( true );
+ m_databaseStatus->setText( " " );
+ }
+ else
+ {
+ QSqlError error = m_dbConnection->lastError();
+ QString errorMsg;
+ QString err1 = error.driverText();
+ QString err2 = error.databaseText();
+ if ( !err1.isEmpty() )
+ {
+ errorMsg.append( error.driverText() );
+ errorMsg.append( "\n" );
+ }
+ if ( !err2.isEmpty() && err1 != err2)
+ {
+ errorMsg.append( error.databaseText() );
+ errorMsg.append( "\n" );
+ }
+ m_databaseStatus->setText( " " );
+
+ KMessageBox::error( this, errorMsg );
+ return false;
+ }
+ }
+ else
+ {
+ KMessageBox::error( this, i18n("Driver couldn't be loaded") );
+ m_databaseStatus->setText( " " );
+ return false;
+ }
+ setNextEnabled(m_table, true);
+
+ return true;
+}
+
+bool KSpreadDatabaseDlg::tablesDoNext()
+{
+ m_databaseStatus->setText( i18n("Retrieving meta data of tables...") );
+ QStringList tables;
+
+ for (QListViewItem * item = (QCheckListItem *) m_tableView->firstChild(); item; item = item->nextSibling())
+ {
+ if (((QCheckListItem * ) item)->isOn())
+ {
+ tables.append(((QCheckListItem * ) item)->text());
+ }
+ }
+
+ if (tables.empty())
+ {
+ KMessageBox::error( this, i18n("You have to select at least one table!") );
+ return false;
+ }
+
+ m_columnView->clear();
+ QSqlRecord info;
+ QCheckListItem * item;
+ for (int i = 0; i < (int) tables.size(); ++i)
+ {
+ info = m_dbConnection->record( tables[i] );
+ for (int j = 0; j < (int) info.count(); ++j)
+ {
+ QString name = info.fieldName(j);
+ item = new QCheckListItem( m_columnView, name,
+ QCheckListItem::CheckBox );
+ item->setOn(false);
+ m_columnView->insertItem( item );
+ item->setText( 1, tables[i] );
+ QSqlField * field = info.field(name);
+ item->setText( 2, QVariant::typeToName(field->type()) );
+ }
+ }
+ m_columnView->setSorting(1, true);
+ m_columnView->sort();
+ m_columnView->setSorting( -1 );
+
+ setNextEnabled(m_columns, true);
+
+ return true;
+}
+
+bool KSpreadDatabaseDlg::columnsDoNext()
+{
+ QStringList columns;
+ for (QListViewItem * item = m_columnView->firstChild(); item; item = item->nextSibling())
+ {
+ if (((QCheckListItem * ) item)->isOn())
+ {
+ columns.append( item->text(1) + "." + ((QCheckListItem * ) item)->text());
+ }
+ }
+
+ if (columns.empty())
+ {
+ KMessageBox::error( this, i18n("You have to select at least one column!") );
+ return false;
+ }
+
+ m_columns_1->clear();
+ m_columns_2->clear();
+ m_columns_3->clear();
+ m_columns_1->insertStringList(columns);
+ m_columns_2->insertStringList(columns);
+ m_columns_3->insertStringList(columns);
+ m_columnsSort_1->clear();
+ m_columnsSort_2->clear();
+ m_columnsSort_1->insertItem( i18n("None") );
+ m_columnsSort_2->insertItem( i18n("None") );
+ m_columnsSort_1->insertStringList(columns);
+ m_columnsSort_2->insertStringList(columns);
+
+ setNextEnabled(m_options, true);
+
+ return true;
+}
+
+
+QString KSpreadDatabaseDlg::getWhereCondition(QString const & column,
+ QString const & value,
+ int op)
+{
+ QString wherePart;
+
+ switch( op )
+ {
+ case 0:
+ wherePart += column;
+ wherePart += " = ";
+ break;
+ case 1:
+ wherePart += "NOT ";
+ wherePart += column;
+ wherePart += " = ";
+ break;
+ case 2:
+ wherePart += column;
+ wherePart += " IN ";
+ break;
+ case 3:
+ wherePart += "NOT ";
+ wherePart += column;
+ wherePart += " IN ";
+ break;
+ case 4:
+ wherePart += column;
+ wherePart += " LIKE ";
+ break;
+ case 5:
+ wherePart += column;
+ wherePart += " > ";
+ break;
+ case 6:
+ wherePart += column;
+ wherePart += " < ";
+ break;
+ case 7:
+ wherePart += column;
+ wherePart += " >= ";
+ break;
+ case 8:
+ wherePart += column;
+ wherePart += " <= ";
+ break;
+ }
+
+ if ( op != 2 && op != 3 )
+ {
+ QString val;
+ bool ok = false;
+ value.toDouble(&ok);
+
+ if ( !ok )
+ {
+ if (value[0] != '\'')
+ val = "'";
+
+ val += value;
+
+ if (value[value.length() - 1] != '\'')
+ val += "'";
+ }
+ else
+ val = value;
+
+ wherePart += val;
+ }
+ else // "in" & "not in"
+ {
+ QString val;
+ if (value[0] != '(')
+ val = "(";
+ val += value;
+ if ( value[value.length() - 1] != ')' )
+ val += ")";
+ wherePart += val;
+ }
+
+ return wherePart;
+}
+
+QString KSpreadDatabaseDlg::exchangeWildcards(QString const & value)
+{
+ QString str(value);
+ int p = str.find('*');
+ while ( p > -1 )
+ {
+ str = str.replace( p, 1, "%" );
+ p = str.find('*');
+ }
+
+ p = str.find('?');
+ while ( p > -1 )
+ {
+ str = str.replace( p, 1, "_" );
+ p = str.find('?');
+ }
+ return str;
+}
+
+bool KSpreadDatabaseDlg::optionsDoNext()
+{
+ if ( m_operator_1->currentItem() == 4 )
+ {
+ if ( ( m_operatorValue_1->text().find('*') != -1 )
+ || ( m_operatorValue_1->text().find('?') != -1 ) )
+ {
+ int res = KMessageBox::warningYesNo( this, i18n("'*' or '?' are no valid wildcards in SQL. "
+ " The proper replacements are '%' or '_'. Do you want to replace them?") );
+
+ if ( res == KMessageBox::Yes )
+ m_operatorValue_1->setText(exchangeWildcards(m_operatorValue_1->text()));
+ }
+ }
+
+ if ( m_operator_2->currentItem() == 4 )
+ {
+ if ( ( m_operatorValue_2->text().find('*') != -1 )
+ || ( m_operatorValue_2->text().find('?') != -1 ) )
+ {
+ int res = KMessageBox::warningYesNo( this, i18n("'*' or '?' are no valid wildcards in SQL. "
+ " The proper replacements are '%' or '_'. Do you want to replace them?") );
+
+ if ( res == KMessageBox::Yes )
+ m_operatorValue_2->setText(exchangeWildcards(m_operatorValue_2->text()));
+ }
+ }
+
+ if ( m_operator_3->currentItem() == 4 )
+ {
+ if ( ( m_operatorValue_3->text().find('*') != -1 )
+ || ( m_operatorValue_3->text().find('?') != -1 ) )
+ {
+ int res = KMessageBox::warningYesNo( this, i18n("'*' or '?' are no valid wildcards in SQL. "
+ " The proper replacements are '%' or '_'. Do you want to replace them?") );
+
+ if ( res == KMessageBox::Yes )
+ m_operatorValue_3->setText(exchangeWildcards(m_operatorValue_3->text()));
+ }
+ }
+
+ QString query("SELECT ");
+
+ if (m_distinct->isChecked())
+ query += "DISTINCT ";
+
+ int i;
+ int l = m_columns_1->count() - 1;
+ for ( i = 0; i < l; ++i )
+ {
+ query += m_columns_1->text( i );
+ query += ", ";
+ }
+ query += m_columns_1->text( l );
+
+ query += "\nFROM ";
+
+ QListViewItem * item = (QCheckListItem *) m_tableView->firstChild();
+ bool b = false;
+ while ( item )
+ {
+ if (((QCheckListItem * ) item)->isOn())
+ {
+ if ( b )
+ query += ", ";
+ b = true;
+ query += ((QCheckListItem * ) item)->text();
+ }
+ item = item->nextSibling();
+ }
+
+ if ( ( !m_operatorValue_1->text().isEmpty() )
+ || ( !m_operatorValue_2->text().isEmpty() )
+ || ( !m_operatorValue_3->text().isEmpty() ) )
+ query += "\nWHERE ";
+
+ bool added = false;
+ if ( !m_operatorValue_1->text().isEmpty() )
+ {
+ query += getWhereCondition(m_columns_1->currentText(),
+ m_operatorValue_1->text(),
+ m_operator_1->currentItem());
+ added = true;
+ }
+
+ if ( !m_operatorValue_2->text().isEmpty() )
+ {
+ if (added)
+ query += ( m_andBox->isChecked() ? " AND " : " OR " );
+
+ query += getWhereCondition(m_columns_2->currentText(),
+ m_operatorValue_2->text(),
+ m_operator_2->currentItem());
+ added = true;
+ }
+
+ if ( !m_operatorValue_3->text().isEmpty() )
+ {
+ if (added)
+ query += ( m_andBox->isChecked() ? " AND " : " OR " );
+
+ query += getWhereCondition(m_columns_3->currentText(),
+ m_operatorValue_3->text(),
+ m_operator_3->currentItem());
+ }
+
+ if ( (m_columnsSort_1->currentItem() != 0)
+ || (m_columnsSort_2->currentItem() != 0) )
+ {
+ query += "\nORDER BY ";
+ bool added = false;
+ if ( m_columnsSort_1->currentItem() != 0 )
+ {
+ added = true;
+ query += m_columnsSort_1->currentText();
+ if ( m_sortMode_1->currentItem() == 1 )
+ query += " DESC ";
+ }
+
+ if ( m_columnsSort_2->currentItem() != 0 )
+ {
+ if ( added )
+ query += ", ";
+
+ query += m_columnsSort_2->currentText();
+ if ( m_sortMode_2->currentItem() == 1 )
+ query += " DESC ";
+ }
+ }
+
+ m_sqlQuery->setText(query);
+ m_cell->setText(util_cellName( m_targetRect.left(), m_targetRect.top() ) );
+ m_region->setText(util_rangeName( m_targetRect ) );
+
+ setFinishEnabled( m_result, true );
+
+ return true;
+}
+
+void KSpreadDatabaseDlg::orBox_clicked()
+{
+ m_andBox->setChecked( false );
+ m_orBox->setChecked( true );
+}
+
+void KSpreadDatabaseDlg::andBox_clicked()
+{
+ m_andBox->setChecked( true );
+ m_orBox->setChecked( false );
+}
+
+void KSpreadDatabaseDlg::startingCell_clicked()
+{
+ m_startingCell->setChecked( true );
+ m_startingRegion->setChecked( false );
+}
+
+void KSpreadDatabaseDlg::startingRegion_clicked()
+{
+ m_startingCell->setChecked( false );
+ m_startingRegion->setChecked( true );
+}
+
+void KSpreadDatabaseDlg::connectButton_clicked()
+{
+ qWarning( "KSpreadDatabaseDlg::connectButton_clicked(): Not implemented yet!" );
+}
+
+void KSpreadDatabaseDlg::databaseNameChanged(const QString & s)
+{
+ if ( !m_driver->currentText().isEmpty() && !s.isEmpty()
+ && !m_host->text().isEmpty() )
+ setNextEnabled(m_database, true);
+ else
+ setNextEnabled(m_database, false);
+}
+
+void KSpreadDatabaseDlg::databaseHostChanged(const QString & s)
+{
+ if ( !m_driver->currentText().isEmpty() && !s.isEmpty()
+ && !m_databaseName->text().isEmpty() )
+ setNextEnabled(m_database, true);
+ else
+ setNextEnabled(m_database, false);
+}
+
+void KSpreadDatabaseDlg::databaseDriverChanged(int index)
+{
+ if ( index > 0 && !m_host->text().isEmpty()
+ && !m_databaseName->text().isEmpty() )
+ setNextEnabled(m_database, true);
+ else
+ setNextEnabled(m_database, false);
+}
+
+void KSpreadDatabaseDlg::popupTableViewMenu( QListViewItem *, const QPoint &, int )
+{
+ // TODO: popup menu with "Select All", "Inverse selection", "remove selection"
+}
+
+void KSpreadDatabaseDlg::tableViewClicked( QListViewItem * )
+{
+// if ( item )
+// {
+// QCheckListItem * i = (QCheckListItem *) item;
+// i->setOn( !i->isOn() );
+// }
+// kdDebug() << "clicked" << endl;
+}
+
+#include "kspread_dlg_database.moc"
+
diff --git a/kspread/kspread_dlg_database.h b/kspread/kspread_dlg_database.h
new file mode 100644
index 0000000000..dc222a84cf
--- /dev/null
+++ b/kspread/kspread_dlg_database.h
@@ -0,0 +1,139 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Norbert Andres, nandres@web.de
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __kspread_dlg_database__
+#define __kspread_dlg_database__
+
+#include
+#include
+#include
+
+#include
+
+class KSpreadView;
+
+class QCheckBox;
+class QComboBox;
+class QFrame;
+class QGridLayout;
+class QLabel;
+class QLineEdit;
+class QListViewItem;
+class QHBoxLayout;
+class QRadioButton;
+class QSqlDatabase;
+class QTextEdit;
+class QVBoxLayout;
+class QWidget;
+
+class KListView;
+class KPushButton;
+
+class KSpreadDatabaseDlg : public KWizard
+{
+ Q_OBJECT
+
+ public:
+ enum PageId { eDatabase = 0, eTables = 1, eColumns = 2, eOptions = 3, eResult = 4 };
+
+ KSpreadDatabaseDlg( KSpreadView * parent, QRect const & rect, const char * name = 0, bool modal = FALSE, WFlags fl = 0 );
+ virtual ~KSpreadDatabaseDlg();
+
+ private slots:
+ void orBox_clicked();
+ void andBox_clicked();
+ void startingCell_clicked();
+ void startingRegion_clicked();
+ void connectButton_clicked();
+ void databaseNameChanged( const QString & s );
+ void databaseHostChanged( const QString & s );
+ void databaseDriverChanged( int );
+ void popupTableViewMenu( QListViewItem *, const QPoint &, int );
+ void tableViewClicked( QListViewItem * );
+ void accept();
+
+ protected:
+ void next();
+ void back();
+
+ QGridLayout * m_databaseLayout;
+ QGridLayout * m_tableLayout;
+ QGridLayout * m_columnsLayout;
+ QGridLayout * m_optionsLayout;
+ QGridLayout * m_resultLayout;
+
+ private:
+ int m_currentPage;
+ KSpreadView * m_pView;
+ QRect m_targetRect;
+ QSqlDatabase * m_dbConnection;
+
+ QWidget * m_database;
+ QLabel * m_databaseStatus;
+ QLineEdit * m_username;
+ QLineEdit * m_port;
+ QLineEdit * m_databaseName;
+ QComboBox * m_driver;
+ QLineEdit * m_password;
+ QLineEdit * m_host;
+ QLabel * m_Type;
+ QWidget * m_table;
+ QComboBox * m_databaseList;
+ KPushButton * m_connectButton;
+ QLabel * m_tableStatus;
+ QLabel * m_SelectTableLabel;
+ KListView * m_tableView;
+ QWidget * m_columns;
+ KListView * m_columnView;
+ QLabel * m_columnsStatus;
+ QWidget * m_options;
+ QComboBox * m_columns_1;
+ QComboBox * m_columns_2;
+ QComboBox * m_columns_3;
+ QComboBox * m_operator_1;
+ QComboBox * m_operator_2;
+ QComboBox * m_operator_3;
+ QLineEdit * m_operatorValue_1;
+ QLineEdit * m_operatorValue_2;
+ QLineEdit * m_operatorValue_3;
+ QRadioButton * m_andBox;
+ QRadioButton * m_orBox;
+ QComboBox * m_columnsSort_1;
+ QComboBox * m_columnsSort_2;
+ QComboBox * m_sortMode_1;
+ QComboBox * m_sortMode_2;
+ QCheckBox * m_distinct;
+ QWidget * m_result;
+ QTextEdit * m_sqlQuery;
+ QRadioButton * m_startingRegion;
+ QLineEdit * m_cell;
+ QLineEdit * m_region;
+ QRadioButton * m_startingCell;
+
+ void switchPage( int id );
+ bool databaseDoNext();
+ bool tablesDoNext();
+ bool columnsDoNext();
+ bool optionsDoNext();
+
+ QString exchangeWildcards(QString const & value);
+ QString getWhereCondition( QString const &, QString const &, int );
+};
+
+#endif
diff --git a/kspread/kspread_view.cc b/kspread/kspread_view.cc
index e88796fdf7..d90de7a68e 100644
--- a/kspread/kspread_view.cc
+++ b/kspread/kspread_view.cc
@@ -1,4534 +1,4614 @@
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include // has to be first
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "kspread_map.h"
#include "kspread_dlg_scripts.h"
#include "kspread_dlg_cons.h"
+#include "kspread_dlg_database.h"
#include "kspread_canvas.h"
#include "kspread_tabbar.h"
#include "kspread_dlg_formula.h"
#include "kspread_dlg_special.h"
#include "kspread_dlg_sort.h"
#include "kspread_dlg_anchor.h"
#include "kspread_dlg_layout.h"
#include "kspread_dlg_show.h"
#include "kspread_dlg_insert.h"
#include "kspread_handler.h"
#include "kspread_events.h"
#include "kspread_editors.h"
#include "kspread_dlg_format.h"
// #include "kspread_dlg_oszi.h"
#include "kspread_dlg_conditional.h"
#include "kspread_dlg_series.h"
#include "kspread_dlg_reference.h"
#include "kspread_dlg_area.h"
#include "kspread_dlg_resize2.h"
#include "kspread_dlg_preference.h"
#include "kspread_dlg_comment.h"
#include "kspread_dlg_angle.h"
#include "kspread_dlg_goto.h"
#include "kspread_dlg_validity.h"
#include "kspread_dlg_pasteinsert.h"
#include "kspread_dlg_showColRow.h"
#include "kspread_dlg_list.h"
#include "kspread_undo.h"
#include "handler.h"
#include "KSpreadViewIface.h"
#include
#include
#include
/*****************************************************************************
*
* KSpreadView
*
*****************************************************************************/
KSpreadScripts* KSpreadView::m_pGlobalScriptsDialog = 0L;
// non flickering version of KSpell.
class KSpreadSpell : public KSpell
{
public:
KSpreadSpell(QWidget *parent, const QString &caption,
QObject *receiver, const char *slot, KSpellConfig *kcs=0,
bool progressbar = FALSE, bool modal = true )
: KSpell(parent, caption, receiver, slot, kcs, progressbar, modal)
{
}
// override check(...)
// mostly copied from kdelibs/kspell/kspell.cpp
// the dialog gets created but it gets only shown if something
// is misspelled. Otherwise for every cell the dialog would pop up
// and disappear
bool check( const QString &_buffer, bool _usedialog = true )
{
QString qs;
usedialog=_usedialog;
setUpDialog ();
//set the dialog signal handler
dialog3slot = SLOT (check3 ());
kdDebug(750) << "KS: check" << endl;
origbuffer = _buffer;
if ( ( totalpos = origbuffer.length() ) == 0 )
{
emit done(origbuffer);
return FALSE;
}
// Torben: I corrected the \n\n problem directly in the
// origbuffer since I got errors otherwise
if ( origbuffer.right(2) != "\n\n" )
{
if (origbuffer.at(origbuffer.length() - 1) != '\n')
{
origbuffer += '\n';
origbuffer += '\n'; //shouldn't these be removed at some point?
}
else
origbuffer += '\n';
}
newbuffer = origbuffer;
// KProcIO calls check2 when read from ispell
connect(proc, SIGNAL (readReady(KProcIO *)), this, SLOT (check2(KProcIO *)));
proc->fputs ("!");
//lastpos is a position in newbuffer (it has offset in it)
offset = lastlastline = lastpos = lastline = 0;
emitProgress ();
// send first buffer line
int i = origbuffer.find('\n', 0) + 1;
qs = origbuffer.mid (0, i);
cleanFputs(qs, FALSE);
lastline = i; //the character position, not a line number
ksdlg->hide();
return TRUE;
}
// mostly copied from kdelibs/kspell/kspell.cpp
void check2 (KProcIO *)
{
int e, tempe;
QString word;
QString line;
do
{
tempe = proc->fgets (line); //get ispell's response
if (tempe > 0)
{
e = parseOneResponse(line, word, sugg);
if ( (e == 3) // mistake
|| (e == 2) ) // replace
{
dlgresult =- 1;
// for multibyte encoding posinline needs correction
if (ksconfig->encoding() == KS_E_UTF8)
{
// convert line to UTF-8, cut at pos, convert back to UCS-2
// and get string length
posinline = (QString::fromUtf8(origbuffer.mid(lastlastline,
lastline - lastlastline).utf8(),
posinline)).length();
}
lastpos = posinline + lastlastline + offset;
//orig is set by parseOneResponse()
if (e == 2) // replace
{
dlgreplacement = word;
emit corrected (orig, replacement(), lastpos);
offset += replacement().length() - orig.length();
newbuffer.replace (lastpos, orig.length(), word);
}
else //MISTAKE
{
cwword = word;
if ( usedialog )
{
// show the word in the dialog
ksdlg->show();
dialog (word, sugg, SLOT (check3()));
}
else
{
// No dialog, just emit misspelling and continue
emit misspelling (word, sugg, lastpos);
dlgresult = KS_IGNORE;
check3();
}
return;
}
}
}
emitProgress (); //maybe
} while (tempe > 0);
proc->ackRead();
if (tempe == -1) //we were called, but no data seems to be ready...
return;
//If there is more to check, then send another line to ISpell.
if ((unsigned int)lastline < origbuffer.length())
{
int i;
QString qs;
lastpos = (lastlastline = lastline) + offset; //do we really want this?
i = origbuffer.find('\n', lastline)+1;
qs = origbuffer.mid (lastline, i-lastline);
cleanFputs (qs, FALSE);
lastline = i;
return;
}
else
//This is the end of it all
{
ksdlg->hide();
newbuffer.truncate (newbuffer.length()-2);
emitProgress();
emit done (newbuffer);
}
}
};
KSpreadView::KSpreadView( QWidget *_parent, const char *_name, KSpreadDoc* doc ) :
KoView( doc, _parent, _name )
{
kdDebug(36001) << "sizeof(KSpreadCell)=" << sizeof(KSpreadCell) <setRange( 0, 4096 );
m_pVertScrollBar->setOrientation( QScrollBar::Vertical );
// Horz. Scroll Bar
m_pHorzScrollBar = new QScrollBar( this, "ScrollBar_1" );
m_pHorzScrollBar->setRange( 0, 4096 );
m_pHorzScrollBar->setOrientation( QScrollBar::Horizontal );
// Tab Bar
m_pTabBarFirst = newIconButton( "tab_first" );
QObject::connect( m_pTabBarFirst, SIGNAL( clicked() ), SLOT( slotScrollToFirstTable() ) );
m_pTabBarLeft = newIconButton( "tab_left" );
QObject::connect( m_pTabBarLeft, SIGNAL( clicked() ), SLOT( slotScrollToLeftTable() ) );
m_pTabBarRight = newIconButton( "tab_right" );
QObject:: connect( m_pTabBarRight, SIGNAL( clicked() ), SLOT( slotScrollToRightTable() ) );
m_pTabBarLast = newIconButton( "tab_last" );
QObject::connect( m_pTabBarLast, SIGNAL( clicked() ), SLOT( slotScrollToLastTable() ) );
m_pTabBar = new KSpreadTabBar( this );
QObject::connect( m_pTabBar, SIGNAL( tabChanged( const QString& ) ), this, SLOT( changeTable( const QString& ) ) );
// Paper and Border widgets
m_pFrame = new QWidget( this );
m_pFrame->raise();
// Edit Bar
m_pToolWidget = new QFrame( this );
QHBoxLayout* hbox = new QHBoxLayout( m_pToolWidget );
hbox->addSpacing( 2 );
m_pPosWidget = new KSpreadLocationEditWidget( m_pToolWidget, this );
m_pPosWidget->setMinimumWidth( 100 );
hbox->addWidget( m_pPosWidget );
hbox->addSpacing( 6 );
m_pCancelButton = newIconButton( "abort", TRUE, m_pToolWidget );
hbox->addWidget( m_pCancelButton );
m_pOkButton = newIconButton( "done", TRUE, m_pToolWidget );
hbox->addWidget( m_pOkButton );
hbox->addSpacing( 6 );
// The widget on which we display the table
m_pCanvas = new KSpreadCanvas( m_pFrame, this, doc );
// The line-editor that appears above the table and allows to
// edit the cells content. It knows about the two buttons.
m_pEditWidget = new KSpreadEditWidget( m_pToolWidget, m_pCanvas, m_pCancelButton, m_pOkButton );
m_pEditWidget->setFocusPolicy( QWidget::StrongFocus );
hbox->addWidget( m_pEditWidget, 2 );
hbox->addSpacing( 2 );
m_pCanvas->setEditWidget( m_pEditWidget );
m_pHBorderWidget = new KSpreadHBorder( m_pFrame, m_pCanvas,this );
m_pVBorderWidget = new KSpreadVBorder( m_pFrame, m_pCanvas ,this );
m_pCanvas->setFocusPolicy( QWidget::StrongFocus );
QWidget::setFocusPolicy( QWidget::StrongFocus );
setFocusProxy( m_pCanvas );
connect( this, SIGNAL( invalidated() ), m_pCanvas, SLOT( update() ) );
connect( this, SIGNAL( regionInvalidated( const QRegion&, bool ) ),
m_pCanvas, SLOT( repaint( const QRegion&, bool ) ) );
QObject::connect( m_pVertScrollBar, SIGNAL( valueChanged(int) ), m_pCanvas, SLOT( slotScrollVert(int) ) );
QObject::connect( m_pHorzScrollBar, SIGNAL( valueChanged(int) ), m_pCanvas, SLOT( slotScrollHorz(int) ) );
KSpreadTable *tbl;
for ( tbl = m_pDoc->map()->firstTable(); tbl != 0L; tbl = m_pDoc->map()->nextTable() )
addTable( tbl );
tbl = m_pDoc->map()->initialActiveTable();
if (tbl)
setActiveTable(tbl);
else
//activate first table which is not hiding
setActiveTable(m_pDoc->map()->findTable(m_pTabBar->listshow().first()));
QObject::connect( m_pDoc, SIGNAL( sig_addTable( KSpreadTable* ) ), SLOT( slotAddTable( KSpreadTable* ) ) );
QObject::connect( m_pDoc, SIGNAL( sig_refreshView( ) ), this, SLOT( slotRefreshView() ) );
QObject::connect( m_pDoc, SIGNAL( sig_refreshLocale() ), this, SLOT( slotRefreshLocale()));
// Handler for moving and resizing embedded parts
ContainerHandler* h = new ContainerHandler( this, m_pCanvas );
connect( h, SIGNAL( popupMenu( KoChild*, const QPoint& ) ), this, SLOT( popupChildMenu( KoChild*, const QPoint& ) ) );
connect( this, SIGNAL( childSelected( KoDocumentChild* ) ),
this, SLOT( slotChildSelected( KoDocumentChild* ) ) );
connect( this, SIGNAL( childUnselected( KoDocumentChild* ) ),
this, SLOT( slotChildUnselected( KoDocumentChild* ) ) );
// If a selected part becomes active this is like it is deselected
// just before.
connect( this, SIGNAL( childActivated( KoDocumentChild* ) ),
this, SLOT( slotChildUnselected( KoDocumentChild* ) ) );
QTimer::singleShot( 0, this, SLOT( initialPosition() ) );
m_findOptions = 0;
KStatusBar * sb = statusBar();
Q_ASSERT(sb);
m_sbCalcLabel = sb ? new KStatusBarLabel( QString::null, 0, sb ) : 0;
addStatusBarItem( m_sbCalcLabel, 0 );
if(m_sbCalcLabel)
connect(m_sbCalcLabel ,SIGNAL(itemPressed( int )),this,SLOT(statusBarClicked(int)));
initializeCalcActions();
initializeInsertActions();
initializeEditActions();
initializeAreaOperationActions();
initializeGlobalOperationActions();
initializeCellOperationActions();
initializeCellPropertyActions();
initializeTextFormatActions();
initializeTextLayoutActions();
initializeTextPropertyActions();
initializeTableActions();
initializeSpellChecking();
initializeRowColumnActions();
initializeBorderActions();
}
void KSpreadView::initializeCalcActions()
{
//menu calc
/*******************************/
m_menuCalcSum = new KToggleAction( i18n("Sum"), 0, actionCollection(),
"menu_sum");
connect( m_menuCalcSum, SIGNAL( toggled( bool ) ), this,
SLOT( menuCalc( bool ) ) );
m_menuCalcSum->setExclusiveGroup( "Calc" );
- m_menuCalcSum->setToolTip("Calculate using sum.");
+ m_menuCalcSum->setToolTip(i18n("Calculate using sum."));
/*******************************/
m_menuCalcMin = new KToggleAction( i18n("Min"), 0, actionCollection(),
"menu_min");
connect( m_menuCalcMin, SIGNAL( toggled( bool ) ), this,
SLOT( menuCalc( bool ) ) );
m_menuCalcMin->setExclusiveGroup( "Calc" );
- m_menuCalcMin->setToolTip("Calculate using minimum.");
+ m_menuCalcMin->setToolTip(i18n("Calculate using minimum."));
/*******************************/
m_menuCalcMax = new KToggleAction( i18n("Max"), 0, actionCollection(),
"menu_max");
connect( m_menuCalcMax, SIGNAL( toggled( bool ) ), this,
SLOT( menuCalc( bool ) ) );
m_menuCalcMax->setExclusiveGroup( "Calc" );
- m_menuCalcMax->setToolTip("Calculate using maximum.");
+ m_menuCalcMax->setToolTip(i18n("Calculate using maximum."));
/*******************************/
m_menuCalcAverage = new KToggleAction( i18n("Average"), 0, actionCollection(),
"menu_average");
connect( m_menuCalcAverage, SIGNAL( toggled( bool ) ), this,
SLOT( menuCalc( bool ) ) );
m_menuCalcAverage->setExclusiveGroup( "Calc" );
- m_menuCalcAverage->setToolTip("Calculate using average.");
+ m_menuCalcAverage->setToolTip(i18n("Calculate using average."));
/*******************************/
m_menuCalcCount = new KToggleAction( i18n("Count"), 0, actionCollection(),
"menu_count");
connect( m_menuCalcCount, SIGNAL( toggled( bool ) ), this,
SLOT( menuCalc( bool ) ) );
m_menuCalcCount->setExclusiveGroup( "Calc" );
- m_menuCalcCount->setToolTip("Calculate using the count.");
+ m_menuCalcCount->setToolTip(i18n("Calculate using the count."));
/*******************************/
m_menuCalcNone = new KToggleAction( i18n("None"), 0, actionCollection(),
"menu_none");
connect( m_menuCalcNone, SIGNAL( toggled( bool ) ), this,
SLOT( menuCalc( bool ) ) );
m_menuCalcNone->setExclusiveGroup( "Calc" );
- m_menuCalcNone->setToolTip("No calculation.");
+ m_menuCalcNone->setToolTip(i18n("No calculation."));
/*******************************/
}
void KSpreadView::initializeInsertActions()
{
KAction* tmpAction = NULL;
tmpAction = new KAction( i18n("&Math Expression..."), "funct", 0, this,
SLOT( insertMathExpr() ), actionCollection(),
"insertMathExpr" );
- tmpAction->setToolTip("Insert math expression.");
+ tmpAction->setToolTip(i18n("Insert math expression."));
tmpAction = new KAction( i18n("&Series..."),"series", 0, this,
SLOT( insertSeries() ), actionCollection(), "series");
- tmpAction ->setToolTip("Insert a series.");
+ tmpAction ->setToolTip(i18n("Insert a series."));
tmpAction = new KAction( i18n("&Hyperlink..."), 0, this,
SLOT( insertHyperlink() ), actionCollection(),
"insertHyperlink" );
- tmpAction->setToolTip("Insert an internet hyperlink.");
+ tmpAction->setToolTip(i18n("Insert an internet hyperlink."));
m_insertPart=new KoPartSelectAction( i18n("&Object..."), "frame_query", this,
SLOT( insertObject() ),
actionCollection(), "insertPart");
- m_insertPart->setToolTip("Insert an object from another program.");
+ m_insertPart->setToolTip(i18n("Insert an object from another program."));
m_insertChartFrame=new KAction( i18n("&Chart"), "frame_chart", 0, this,
SLOT( insertChart() ), actionCollection(),
"insertChart" );
- m_insertChartFrame->setToolTip("Insert a chart.");
+ m_insertChartFrame->setToolTip(i18n("Insert a chart."));
+ m_insertFromDatabase = new KAction( i18n("From &Database"), 0, this,
+ SLOT( insertFromDatabase() ),
+ actionCollection(), "insertFromDatabase");
+ m_insertFromDatabase->setToolTip(i18n("Insert data from a SQL database"));
+ m_insertFromTextfile = new KAction( i18n("From &Text File"), 0, this,
+ SLOT( insertFromTextfile() ),
+ actionCollection(), "insertFromTextfile");
+ m_insertFromTextfile->setToolTip(i18n("Insert data from a text file to the current cursor position/selection"));
+ m_insertFromClipboard = new KAction( i18n("From &Clipboard"), 0, this,
+ SLOT( insertFromClipboard() ),
+ actionCollection(), "insertFromClipboard");
+ m_insertFromClipboard->setToolTip(i18n("Insert csv data from the clipboard to the current cursor position/selection"));
+
}
void KSpreadView::initializeEditActions()
{
m_copy = KStdAction::copy( this, SLOT( copySelection() ), actionCollection(),
"copy" );
- m_copy->setToolTip("Copy the cell object to the clipboard.");
+ m_copy->setToolTip(i18n("Copy the cell object to the clipboard."));
m_paste = KStdAction::paste( this, SLOT( paste() ), actionCollection(),
"paste" );
- m_paste->setToolTip("Paste the contents of the clipboard at the cursor");
+ m_paste->setToolTip(i18n("Paste the contents of the clipboard at the cursor"));
m_cut = KStdAction::cut( this, SLOT( cutSelection() ), actionCollection(),
"cut" );
- m_cut->setToolTip("Move the cell object to the clipboard.");
+ m_cut->setToolTip(i18n("Move the cell object to the clipboard."));
m_specialPaste = new KAction( i18n("Special Paste..."), "special_paste",0,
this, SLOT( specialPaste() ), actionCollection(),
"specialPaste" );
m_specialPaste->setToolTip
- ("Paste the contents of the clipboard with special options.");
+ (i18n("Paste the contents of the clipboard with special options."));
m_undo = KStdAction::undo( this, SLOT( undo() ), actionCollection(), "undo" );
m_undo->setEnabled( FALSE );
- m_undo->setToolTip("Undo the previous action.");
+ m_undo->setToolTip(i18n("Undo the previous action."));
m_redo = KStdAction::redo( this, SLOT( redo() ), actionCollection(), "redo" );
m_redo->setEnabled( FALSE );
- m_redo->setToolTip("Redo the action that has been undone.");
+ m_redo->setToolTip(i18n("Redo the action that has been undone."));
KStdAction::find(this, SLOT(find()), actionCollection());
KStdAction::replace(this, SLOT(replace()), actionCollection());
}
void KSpreadView::initializeAreaOperationActions()
{
m_areaName = new KAction( i18n("Area Name..."), 0, this,
SLOT( setAreaName() ), actionCollection(),
"areaname" );
- m_areaName->setToolTip("Set a name for a region of the spreadsheet");
+ m_areaName->setToolTip(i18n("Set a name for a region of the spreadsheet"));
m_showArea = new KAction( i18n("Show Area..."), 0, this,
SLOT( showAreaName() ), actionCollection(),
"showArea" );
- m_showArea->setToolTip("Display a named area");
+ m_showArea->setToolTip(i18n("Display a named area"));
m_sortList = new KAction( i18n("Custom Lists..."), 0, this,
SLOT( sortList() ), actionCollection(),
"sortlist" );
- m_sortList->setToolTip(""); /* TODO - what does this do? */
+ m_sortList->setToolTip(i18n("Create custom lists for sorting or auto fill"));
m_sort = new KAction( i18n("Sort..."), 0, this, SLOT( sort() ),
actionCollection(), "sort" );
- m_sort->setToolTip("Sort a group of cells.");
+ m_sort->setToolTip(i18n("Sort a group of cells."));
m_autoSum = new KAction( i18n("AutoSum"), "black_sum", 0, this,
SLOT( autoSum() ), actionCollection(), "autoSum" );
- m_autoSum->setToolTip("Insert the 'sum' function");
+ m_autoSum->setToolTip(i18n("Insert the 'sum' function"));
m_sortDec = new KAction( i18n("Sort Decreasing"), "sort_decrease", 0, this,
SLOT( sortDec() ), actionCollection(), "sortDec" );
- m_sortDec->setToolTip("Sort a group of cells in decreasing (last to first) order.");
+ m_sortDec->setToolTip(i18n("Sort a group of cells in decreasing (last to first) order."));
m_sortInc = new KAction( i18n("Sort Increasing"), "sort_incr", 0, this,
SLOT( sortInc() ), actionCollection(), "sortInc" );
- m_sortInc->setToolTip("Sort a group of cells in ascending (first to last) order.");
+ m_sortInc->setToolTip(i18n("Sort a group of cells in ascending (first to last) order."));
m_consolidate = new KAction( i18n("Consolidate..."), 0, this,
SLOT( consolidate() ), actionCollection(),
"consolidate" );
- m_consolidate->setToolTip("Create a region of summary data from a group of similar regions.");
-
+ m_consolidate->setToolTip(i18n("Create a region of summary data from a group of similar regions."));
}
void KSpreadView::initializeGlobalOperationActions()
{
m_recalc_workbook = new KAction( i18n("Recalculate Workbook"), Key_F9, this,
SLOT( RecalcWorkBook() ), actionCollection(),
"RecalcWorkBook" );
- m_recalc_workbook->setToolTip("Recalculate the value of every cell in all worksheets.");
+ m_recalc_workbook->setToolTip(i18n("Recalculate the value of every cell in all worksheets."));
m_recalc_worksheet = new KAction( i18n("Recalculate Sheet"), SHIFT + Key_F9,
this, SLOT( RecalcWorkSheet() ),
actionCollection(), "RecalcWorkSheet" );
- m_recalc_worksheet->setToolTip("Recalculate the value of every cell in the current worksheet.");
+ m_recalc_worksheet->setToolTip(i18n("Recalculate the value of every cell in the current worksheet."));
m_preference = new KAction( i18n("Configure KSpread..."),"configure", 0, this,
SLOT( preference() ), actionCollection(),
"preference" );
- m_preference->setToolTip("Set various KSpread options.");
+ m_preference->setToolTip(i18n("Set various KSpread options."));
m_editGlobalScripts = new KAction( i18n("Edit Global Scripts..."), 0, this,
SLOT( editGlobalScripts() ),
actionCollection(), "editGlobalScripts" );
- m_editGlobalScripts->setToolTip(""); /* TODO - what is this? */
+ m_editGlobalScripts->setToolTip("");//i18n("")); /* TODO - what is this? */
m_editLocalScripts = new KAction( i18n("Edit Local Scripts..."), 0, this,
SLOT( editLocalScripts() ),
actionCollection(), "editLocalScripts" );
- m_editLocalScripts->setToolTip(""); /* TODO - what is this? */
+ m_editLocalScripts->setToolTip("");//i18n("")); /* TODO - what is this? */
m_reloadScripts = new KAction( i18n("Reload Scripts"), 0, this,
SLOT( reloadScripts() ), actionCollection(),
"reloadScripts" );
- m_reloadScripts->setToolTip(""); /* TODO - what is this? */
+ m_reloadScripts->setToolTip("");//i18n("")); /* TODO - what is this? */
m_showPageBorders = new KToggleAction( i18n("Show Page Borders"), 0,
actionCollection(), "showPageBorders");
connect( m_showPageBorders, SIGNAL( toggled( bool ) ), this,
SLOT( togglePageBorders( bool ) ) );
m_showPageBorders->setToolTip("Show on the spreadsheet where the page borders will be.");
m_formulaSelection = new KSelectAction(i18n("Formula Selection"), 0,
actionCollection(), "formulaSelection");
- m_formulaSelection->setToolTip("Insert a formula.");
+ m_formulaSelection->setToolTip(i18n("Insert a formula."));
QStringList lst;
lst.append( "SUM");
lst.append( "AVERAGE");
lst.append( "IF");
lst.append( "COUNT");
lst.append( "MIN");
lst.append( "MAX");
lst.append( i18n("Others...") );
((KSelectAction*) m_formulaSelection)->setItems( lst );
m_formulaSelection->setComboWidth( 80 );
m_formulaSelection->setCurrentItem(0);
connect( m_formulaSelection, SIGNAL( activated( const QString& ) ),
this, SLOT( formulaSelection( const QString& ) ) );
m_transform = new KAction( i18n("Transform Object..."), "rotate", 0, this,
SLOT( transformPart() ),
actionCollection(), "transform" );
- m_transform->setToolTip("Rotate the contents of the cell.");
+ m_transform->setToolTip(i18n("Rotate the contents of the cell."));
m_transform->setEnabled( FALSE );
connect( m_transform, SIGNAL( activated() ), this, SLOT( transformPart() ) );
m_paperLayout = new KAction( i18n("Paper Layout..."), 0, this,
SLOT( paperLayoutDlg() ), actionCollection(),
"paperLayout" );
- m_paperLayout->setToolTip("Specify the layout of the spreadsheet for a printout.");
+ m_paperLayout->setToolTip(i18n("Specify the layout of the spreadsheet for a printout."));
}
void KSpreadView::initializeCellOperationActions()
{
m_editCell = new KAction( i18n("Modify Cell"),"cell_edit", CTRL + Key_M, this,
SLOT( editCell() ), actionCollection(), "editCell" );
- m_editCell->setToolTip("Edit the highlighted cell.");
+ m_editCell->setToolTip(i18n("Edit the highlighted cell."));
m_delete = new KAction( i18n("Delete"),"deletecell", 0, this,
SLOT( deleteSelection() ), actionCollection(),
"delete" );
- m_delete->setToolTip("Delete all contents and formatting of the current cell.");
+ m_delete->setToolTip(i18n("Delete all contents and formatting of the current cell."));
m_clearText = new KAction( i18n("Text"), 0, this, SLOT( clearTextSelection() ),
actionCollection(), "cleartext" );
- m_clearText->setToolTip("Remove the contents of the current cell.");
+ m_clearText->setToolTip(i18n("Remove the contents of the current cell."));
m_gotoCell = new KAction( i18n("Goto Cell..."),"goto", 0, this,
SLOT( gotoCell() ), actionCollection(), "gotoCell" );
- m_gotoCell->setToolTip("Move to a particular cell.");
+ m_gotoCell->setToolTip(i18n("Move to a particular cell."));
m_mergeCell = new KAction( i18n("Merge Cells"),"mergecell" ,0, this,
SLOT( mergeCell() ), actionCollection(),
"mergecell" );
- m_mergeCell->setToolTip("Merge the selected region into one large cell.");
+ m_mergeCell->setToolTip(i18n("Merge the selected region into one large cell."));
m_dissociateCell = new KAction( i18n("Dissociate Cells"),"dissociatecell" ,0,
this, SLOT( dissociateCell() ),
actionCollection(), "dissociatecell" );
- m_dissociateCell->setToolTip("Unmerge the current cell.");
+ m_dissociateCell->setToolTip(i18n("Unmerge the current cell."));
m_removeCell = new KAction( i18n("Remove Cell(s)..."), "removecell", 0, this,
SLOT( slotRemove() ), actionCollection(),
"removeCell" );
- m_removeCell->setToolTip("Removes the current cell from the spreadsheet.");
+ m_removeCell->setToolTip(i18n("Removes the current cell from the spreadsheet."));
m_insertCellCopy = new KAction( i18n("Paste with Insertion..."),
"insertcellcopy", 0, this,
SLOT( slotInsertCellCopy() ),
actionCollection(), "insertCellCopy" );
- m_insertCellCopy->setToolTip("Inserts a cell from the clipboard into the spreadsheet.");
+ m_insertCellCopy->setToolTip(i18n("Inserts a cell from the clipboard into the spreadsheet."));
m_insertCell = new KAction( i18n("Insert Cell(s)..."), "insertcell", 0, this,
SLOT( slotInsert() ), actionCollection(),
"insertCell" );
- m_insertCell->setToolTip("Insert a blank cell into the spreadsheet.");
+ m_insertCell->setToolTip(i18n("Insert a blank cell into the spreadsheet."));
}
void KSpreadView::initializeCellPropertyActions()
{
m_addModifyComment = new KAction( i18n("&Add/Modify Comment..."),"comment", 0,
this, SLOT( addModifyComment() ),
actionCollection(), "addmodifycomment" );
- m_addModifyComment->setToolTip("Edit a comment for this cell.");
+ m_addModifyComment->setToolTip(i18n("Edit a comment for this cell."));
m_removeComment = new KAction( i18n("&Remove Comment"),"removecomment", 0,
this, SLOT( removeComment() ),
actionCollection(), "removecomment" );
- m_removeComment->setToolTip("Remove this cell's comment.");
+ m_removeComment->setToolTip(i18n("Remove this cell's comment."));
m_conditional = new KAction( i18n("Conditional Cell Attributes..."), 0, this,
SLOT( conditional() ), actionCollection(),
"conditional" );
- m_conditional->setToolTip("Set cell format based on certain conditions.");
+ m_conditional->setToolTip(i18n("Set cell format based on certain conditions."));
m_validity = new KAction( i18n("Validity..."), 0, this, SLOT( validity() ),
actionCollection(), "validity" );
- m_validity->setToolTip("Set tests to confirm cell data is valid.");
+ m_validity->setToolTip(i18n("Set tests to confirm cell data is valid."));
m_clearComment = new KAction( i18n("Comment"), 0, this,
SLOT( clearCommentSelection() ),
actionCollection(), "clearcomment" );
- m_clearComment->setToolTip("Remove this cell's comment.");
+ m_clearComment->setToolTip(i18n("Remove this cell's comment."));
m_clearValidity = new KAction( i18n("Validity"), 0, this,
SLOT( clearValiditySelection() ),
actionCollection(), "clearvalidity" );
- m_clearValidity->setToolTip("Remove the validity tests on this cell.");
+ m_clearValidity->setToolTip(i18n("Remove the validity tests on this cell."));
m_clearConditional = new KAction( i18n("Conditional Cell Attributes"), 0, this,
SLOT( clearConditionalSelection() ),
actionCollection(), "clearconditional" );
- m_clearConditional->setToolTip("Remove the conditional cell formatting.");
+ m_clearConditional->setToolTip(i18n("Remove the conditional cell formatting."));
m_increaseIndent = new KAction( i18n("Increase Indent"),
"format_increaseindent",0, this,
SLOT( increaseIndent() ), actionCollection(),
"increaseindent" );
- m_increaseIndent->setToolTip("Increase the indentation.");
+ m_increaseIndent->setToolTip(i18n("Increase the indentation."));
m_decreaseIndent = new KAction( i18n("Decrease Indent"),
"format_decreaseindent" ,0, this,
SLOT( decreaseIndent() ), actionCollection(),
"decreaseindent");
- m_decreaseIndent->setToolTip("Decrease the indentation.");
+ m_decreaseIndent->setToolTip(i18n("Decrease the indentation."));
m_multiRow = new KToggleAction( i18n("Multi Row"), "multirow", 0,
actionCollection(), "multiRow" );
connect( m_multiRow, SIGNAL( toggled( bool ) ), this,
SLOT( multiRow( bool ) ) );
- m_multiRow->setToolTip("Make the cell text wrap onto multiple lines.");
+ m_multiRow->setToolTip(i18n("Make the cell text wrap onto multiple lines."));
m_cellLayout = new KAction( i18n("Cell Format..."),"cell_layout",
CTRL + ALT + Key_F, this, SLOT( layoutDlg() ),
actionCollection(), "cellLayout" );
- m_cellLayout->setToolTip("Set the cell formatting.");
+ m_cellLayout->setToolTip(i18n("Set the cell formatting."));
m_default = new KAction( i18n("Default"), 0, this, SLOT( defaultSelection() ),
actionCollection(), "default" );
- m_default->setToolTip("Resets to the default format.");
+ m_default->setToolTip(i18n("Resets to the default format."));
m_bgColor = new TKSelectColorAction( i18n("Background color"),
TKSelectColorAction::FillColor,
actionCollection(), "backgroundColor",
true );
connect(m_bgColor,SIGNAL(activated()),SLOT(changeBackgroundColor()));
m_bgColor->setDefaultColor(QColor());
- m_bgColor->setToolTip("Set the background color.");
+ m_bgColor->setToolTip(i18n("Set the background color."));
}
void KSpreadView::initializeTextFormatActions()
{
/*******************************/
m_percent = new KToggleAction( i18n("Percent Format"), "percent", 0,
actionCollection(), "percent");
connect( m_percent, SIGNAL( toggled( bool ) ), this, SLOT( percent( bool ) ) );
- m_percent->setToolTip("Set the cell formatting to look like a percentage.");
+ m_percent->setToolTip(i18n("Set the cell formatting to look like a percentage."));
/*******************************/
m_precplus = new KAction( i18n("Increase Precision"), "prec_plus", 0, this,
SLOT( precisionPlus() ), actionCollection(),
"precplus");
- m_precplus->setToolTip("Increase the decimal precision shown onscreen.");
+ m_precplus->setToolTip(i18n("Increase the decimal precision shown onscreen."));
/*******************************/
m_precminus = new KAction( i18n("Decrease Precision"), "prec_minus", 0, this,
SLOT( precisionMinus() ), actionCollection(),
"precminus");
- m_precminus->setToolTip("Decrease the decimal precision shown onscreen.");
+ m_precminus->setToolTip(i18n("Decrease the decimal precision shown onscreen."));
/*******************************/
m_money = new KToggleAction( i18n("Money Format"), "money", 0,
actionCollection(), "money");
connect( m_money, SIGNAL( toggled( bool ) ), this,
SLOT( moneyFormat( bool ) ) );
- m_money->setToolTip("Set the cell formatting to look like your local currency.");
+ m_money->setToolTip(i18n("Set the cell formatting to look like your local currency."));
/*******************************/
m_upper = new KAction( i18n("Upper Case"), "upper", 0, this,
SLOT( upper() ), actionCollection(), "upper" );
- m_upper->setToolTip("Convert all letters to upper case.");
+ m_upper->setToolTip(i18n("Convert all letters to upper case."));
/*******************************/
m_lower = new KAction( i18n("Lower Case"), "lower", 0, this,
SLOT( lower() ), actionCollection(), "lower" );
- m_lower->setToolTip("Convert all letters to lower case.");
+ m_lower->setToolTip(i18n("Convert all letters to lower case."));
/*******************************/
m_firstLetterUpper = new KAction( i18n("Convert First Letter to Upper Case"),
"first_letter_upper" ,0, this,
SLOT( firstLetterUpper() ),
actionCollection(), "firstletterupper" );
- m_firstLetterUpper->setToolTip("Capitalize the first letter.");
+ m_firstLetterUpper->setToolTip(i18n("Capitalize the first letter."));
}
void KSpreadView::initializeTextLayoutActions()
{
/*******************************/
m_alignLeft = new KToggleAction( i18n("Align Left"), "text_left", 0,
actionCollection(), "left");
connect( m_alignLeft, SIGNAL( toggled( bool ) ), this,
SLOT( alignLeft( bool ) ) );
m_alignLeft->setExclusiveGroup( "Align" );
- m_alignLeft->setToolTip("Left justify the cell contents.");
+ m_alignLeft->setToolTip(i18n("Left justify the cell contents."));
/*******************************/
m_alignCenter = new KToggleAction( i18n("Align Center"), "text_center", 0,
actionCollection(), "center");
connect( m_alignCenter, SIGNAL( toggled( bool ) ), this,
SLOT( alignCenter( bool ) ) );
m_alignCenter->setExclusiveGroup( "Align" );
- m_alignCenter->setToolTip("Center the cell contents.");
+ m_alignCenter->setToolTip(i18n("Center the cell contents."));
/*******************************/
m_alignRight = new KToggleAction( i18n("Align Right"), "text_right", 0,
actionCollection(), "right");
connect( m_alignRight, SIGNAL( toggled( bool ) ), this,
SLOT( alignRight( bool ) ) );
m_alignRight->setExclusiveGroup( "Align" );
- m_alignRight->setToolTip("Right justify the cell contents.");
+ m_alignRight->setToolTip(i18n("Right justify the cell contents."));
/*******************************/
m_alignTop = new KToggleAction( i18n("Align Top"), "text_top", 0,
actionCollection(), "top");
connect( m_alignTop, SIGNAL( toggled( bool ) ), this,
SLOT( alignTop( bool ) ) );
m_alignTop->setExclusiveGroup( "Pos" );
- m_alignTop->setToolTip("Align cell contents along the top of the cell.");
+ m_alignTop->setToolTip(i18n("Align cell contents along the top of the cell."));
/*******************************/
m_alignMiddle = new KToggleAction( i18n("Align Middle"), "middle", 0,
actionCollection(), "middle");
connect( m_alignMiddle, SIGNAL( toggled( bool ) ), this,
SLOT( alignMiddle( bool ) ) );
m_alignMiddle->setExclusiveGroup( "Pos" );
- m_alignMiddle->setToolTip("Align cell contents centered in the cell.");
+ m_alignMiddle->setToolTip(i18n("Align cell contents centered in the cell."));
/*******************************/
m_alignBottom = new KToggleAction( i18n("Align Bottom"), "text_bottom", 0,
actionCollection(), "bottom");
connect( m_alignBottom, SIGNAL( toggled( bool ) ), this,
SLOT( alignBottom( bool ) ) );
m_alignBottom->setExclusiveGroup( "Pos" );
- m_alignBottom->setToolTip("Align cell contents along the bottom of the cell.");
+ m_alignBottom->setToolTip(i18n("Align cell contents along the bottom of the cell."));
/*******************************/
m_verticalText = new KToggleAction( i18n("Vertical Text"),"vertical_text" ,
0 ,actionCollection(), "verticaltext" );
connect( m_verticalText, SIGNAL( toggled( bool ) ), this,
SLOT( verticalText( bool ) ) );
- m_verticalText->setToolTip("Print cell contents vertically.");
+ m_verticalText->setToolTip(i18n("Print cell contents vertically."));
/*******************************/
m_changeAngle = new KAction( i18n("Change Angle..."), 0, this,
SLOT( changeAngle() ), actionCollection(),
"changeangle" );
- m_changeAngle->setToolTip("Change the angle that cell contents are printed.");
+ m_changeAngle->setToolTip(i18n("Change the angle that cell contents are printed."));
}
void KSpreadView::initializeTextPropertyActions()
{
/*******************************/
m_bold = new KToggleAction( i18n("Bold"), "text_bold", CTRL + Key_B,
actionCollection(), "bold");
connect( m_bold, SIGNAL( toggled( bool ) ), this, SLOT( bold( bool ) ) );
/*******************************/
m_italic = new KToggleAction( i18n("Italic"), "text_italic", CTRL + Key_I,
actionCollection(), "italic");
connect( m_italic, SIGNAL( toggled( bool ) ), this, SLOT( italic( bool ) ) );
/*******************************/
m_underline = new KToggleAction( i18n("Underline"), "text_under",
CTRL + Key_U, actionCollection(),
"underline");
connect( m_underline, SIGNAL( toggled( bool ) ), this,
SLOT( underline( bool ) ) );
/*******************************/
m_strikeOut = new KToggleAction( i18n("Strike Out"), "text_strike", 0,
actionCollection(), "strikeout");
connect( m_strikeOut, SIGNAL( toggled( bool ) ), this,
SLOT( strikeOut( bool ) ) );
/*******************************/
m_selectFont = new KFontAction( i18n("Select Font"), 0, actionCollection(),
"selectFont" );
connect( m_selectFont, SIGNAL( activated( const QString& ) ), this,
SLOT( fontSelected( const QString& ) ) );
/*******************************/
m_selectFontSize = new KFontSizeAction( i18n("Select Font Size"), 0,
actionCollection(), "selectFontSize" );
connect( m_selectFontSize, SIGNAL( fontSizeChanged( int ) ), this,
SLOT( fontSizeSelected( int ) ) );
/*******************************/
m_fontSizeUp = new KAction( i18n("Increase Font Size"), "fontsizeup", 0, this,
SLOT( increaseFontSize() ), actionCollection(),
"increaseFontSize" );
/*******************************/
m_fontSizeDown = new KAction( i18n("Decrease Font Size"), "fontsizedown", 0,
this, SLOT( decreaseFontSize() ),
actionCollection(), "decreaseFontSize" );
/*******************************/
m_textColor = new TKSelectColorAction( i18n("Text Color"),
TKSelectColorAction::TextColor,
actionCollection(), "textColor",true );
connect( m_textColor, SIGNAL(activated()), SLOT(changeTextColor()) );
m_textColor->setDefaultColor(QColor());
/*******************************/
}
void KSpreadView::initializeTableActions()
{
m_insertTable = new KAction( i18n("Insert Table"),"inserttable", 0, this,
SLOT( insertTable() ), actionCollection(),
"insertTable" );
- m_insertTable->setToolTip("Insert a new spreadsheet.");
+ m_insertTable->setToolTip(i18n("Insert a new spreadsheet."));
m_removeTable = new KAction( i18n("Remove Table"), "delete_table",0,this,
SLOT( removeTable() ), actionCollection(),
"removeTable" );
- m_removeTable->setToolTip("Remove the spreadsheet.");
+ m_removeTable->setToolTip(i18n("Remove the spreadsheet."));
m_renameTable=new KAction( i18n("Rename Table..."),0,this,
SLOT( slotRename() ), actionCollection(),
"renameTable" );
- m_renameTable->setToolTip("Rename the spreadsheet.");
+ m_renameTable->setToolTip(i18n("Rename the spreadsheet."));
m_nextTable = new KAction( i18n("Next Table"), CTRL + Key_PageDown, this,
SLOT( nextTable() ), actionCollection(),
"nextTable");
- m_nextTable->setToolTip("Move to the next spreadsheet.");
+ m_nextTable->setToolTip(i18n("Move to the next spreadsheet."));
m_prevTable = new KAction( i18n("Previous Table"), CTRL + Key_PageUp, this,
SLOT( previousTable() ), actionCollection(),
"previousTable");
- m_prevTable->setToolTip("Move to the previous spreadsheet.");
+ m_prevTable->setToolTip(i18n("Move to the previous spreadsheet."));
m_firstTable = new KAction( i18n("First Table"), 0, this,
SLOT( firstTable() ), actionCollection(),
"firstTable");
- m_firstTable->setToolTip("Move to the first spreadsheet.");
+ m_firstTable->setToolTip(i18n("Move to the first spreadsheet."));
m_lastTable = new KAction( i18n("Last Table"), 0, this,
SLOT( lastTable() ), actionCollection(),
"lastTable");
- m_lastTable->setToolTip("Move to the last spreadsheet.");
+ m_lastTable->setToolTip(i18n("Move to the last spreadsheet."));
m_showTable = new KAction(i18n("Show Table"),0 ,this,SLOT( showTable()),
actionCollection(), "showTable" );
- m_showTable->setToolTip("Show a hidden spreadsheet.");
+ m_showTable->setToolTip(i18n("Show a hidden spreadsheet."));
m_hideTable = new KAction(i18n("Hide Table"),0 ,this,SLOT( hideTable()),
actionCollection(), "hideTable" );
- m_hideTable->setToolTip("Hide the spreadsheet.");
+ m_hideTable->setToolTip(i18n("Hide the spreadsheet."));
m_tableFormat = new KAction( i18n("Table Style..."), 0, this,
SLOT( tableFormat() ), actionCollection(),
"tableFormat" );
- m_tableFormat->setToolTip("Set the spreadsheet formatting.");
+ m_tableFormat->setToolTip(i18n("Set the spreadsheet formatting."));
}
void KSpreadView::initializeSpellChecking()
{
m_spellChecking = KStdAction::spelling( this, SLOT( extraSpelling() ),
actionCollection(), "spelling" );
- m_spellChecking->setToolTip("Check the spelling.");
+ m_spellChecking->setToolTip(i18n("Check the spelling."));
}
void KSpreadView::initializeRowColumnActions()
{
m_adjust = new KAction( i18n("Adjust Row and Column"), 0, this,
SLOT( adjust() ), actionCollection(), "adjust" );
- m_adjust->setToolTip("Adjusts row/column size so that the contents will fit.");
+ m_adjust->setToolTip(i18n("Adjusts row/column size so that the contents will fit."));
m_resizeRow = new KAction( i18n("Resize Row..."), "resizerow", 0, this,
SLOT( resizeRow() ), actionCollection(),
"resizeRow" );
- m_resizeRow->setToolTip("Change the height of a row.");
+ m_resizeRow->setToolTip(i18n("Change the height of a row."));
m_resizeColumn = new KAction( i18n("Resize Column..."), "resizecol", 0, this,
SLOT( resizeColumn() ), actionCollection(),
"resizeCol" );
- m_resizeColumn->setToolTip("Change the width of a column.");
+ m_resizeColumn->setToolTip(i18n("Change the width of a column."));
m_equalizeRow = new KAction( i18n("Equalize Row"), "adjustrow", 0, this,
SLOT( equalizeRow() ), actionCollection(),
"equalizeRow" );
- m_equalizeRow->setToolTip("Resizes selected rows to be the same size.");
+ m_equalizeRow->setToolTip(i18n("Resizes selected rows to be the same size."));
m_equalizeColumn = new KAction( i18n("Equalize Column"), "adjustcol", 0, this,
SLOT( equalizeColumn() ), actionCollection(),
"equalizeCol" );
- m_equalizeColumn->setToolTip("Resizes selected columns to be the same size.");
+ m_equalizeColumn->setToolTip(i18n("Resizes selected columns to be the same size."));
m_deleteColumn = new KAction( i18n("Delete Column(s)"), "delete_table_col", 0,
this, SLOT( deleteColumn() ),
actionCollection(), "deleteColumn" );
- m_deleteColumn->setToolTip("Removes a column from the spreadsheet.");
+ m_deleteColumn->setToolTip(i18n("Removes a column from the spreadsheet."));
m_deleteRow = new KAction( i18n("Delete Row(s)"), "delete_table_row", 0, this,
SLOT( deleteRow() ), actionCollection(),
"deleteRow" );
- m_deleteRow->setToolTip("Removes a row from the spreadsheet.");
+ m_deleteRow->setToolTip(i18n("Removes a row from the spreadsheet."));
m_insertColumn = new KAction( i18n("Insert Column(s)"), "insert_table_col" ,
0, this, SLOT( insertColumn() ),
actionCollection(), "insertColumn" );
- m_insertColumn->setToolTip("Inserts a new column into the spreadsheet.");
+ m_insertColumn->setToolTip(i18n("Inserts a new column into the spreadsheet."));
m_insertRow = new KAction( i18n("Insert Row(s)"), "insert_table_row", 0, this,
SLOT( insertRow() ), actionCollection(),
"insertRow" );
- m_insertRow->setToolTip("Inserts a new row into the spreadsheet.");
+ m_insertRow->setToolTip(i18n("Inserts a new row into the spreadsheet."));
m_hideRow = new KAction( i18n("Hide Row(s)"), "hide_table_row", 0, this,
SLOT( hideRow() ), actionCollection(), "hideRow" );
- m_hideRow->setToolTip("Hide a row from view.");
+ m_hideRow->setToolTip(i18n("Hide a row from view."));
m_showRow = new KAction( i18n("Show Row(s)"), "show_table_row", 0, this,
SLOT( showRow() ), actionCollection(), "showRow" );
- m_showRow->setToolTip("Show hidden rows.");
+ m_showRow->setToolTip(i18n("Show hidden rows."));
m_showSelRows = new KAction( i18n("Show Row(s)"), "show_table_row", 0, this,
SLOT( showSelRows() ), actionCollection(),
"showSelRows" );
m_showSelRows->setEnabled(false);
- m_showSelRows->setToolTip("Show hidden rows in the selection.");
+ m_showSelRows->setToolTip(i18n("Show hidden rows in the selection."));
m_hideColumn = new KAction( i18n("Hide Column(s)"), "hide_table_column", 0,
this, SLOT( hideColumn() ), actionCollection(),
"hideColumn" );
- m_hideColumn->setToolTip("Hide the column from view.");
+ m_hideColumn->setToolTip(i18n("Hide the column from view."));
m_showColumn = new KAction( i18n("Show Column(s)"), "show_table_column", 0,
this, SLOT( showColumn() ), actionCollection(),
"showColumn" );
- m_showColumn->setToolTip("Show hidden columns.");
+ m_showColumn->setToolTip(i18n("Show hidden columns."));
m_showSelColumns = new KAction( i18n("Show Column(s)"), "show_table_column",
0, this, SLOT( showSelColumns() ),
actionCollection(), "showSelColumns" );
- m_showSelColumns->setToolTip("Show hidden columns in the selection.");
+ m_showSelColumns->setToolTip(i18n("Show hidden columns in the selection."));
m_showSelColumns->setEnabled(false);
}
void KSpreadView::initializeBorderActions()
{
m_borderLeft = new KAction( i18n("Border Left"), "border_left", 0, this,
SLOT( borderLeft() ), actionCollection(),
"borderLeft" );
- m_borderLeft->setToolTip("Set a left border to the selected area.");
+ m_borderLeft->setToolTip(i18n("Set a left border to the selected area."));
m_borderRight = new KAction( i18n("Border Right"), "border_right", 0, this,
SLOT( borderRight() ), actionCollection(),
"borderRight" );
- m_borderRight->setToolTip("Set a right border to the selected area.");
+ m_borderRight->setToolTip(i18n("Set a right border to the selected area."));
m_borderTop = new KAction( i18n("Border Top"), "border_top", 0, this,
SLOT( borderTop() ), actionCollection(),
"borderTop" );
- m_borderTop->setToolTip("Set a top border to the selected area.");
+ m_borderTop->setToolTip(i18n("Set a top border to the selected area."));
m_borderBottom = new KAction( i18n("Border Bottom"), "border_bottom", 0, this,
SLOT( borderBottom() ), actionCollection(),
"borderBottom" );
- m_borderBottom->setToolTip("Set a bottom border to the selected area.");
+ m_borderBottom->setToolTip(i18n("Set a bottom border to the selected area."));
m_borderAll = new KAction( i18n("All Borders"), "border_all", 0, this,
SLOT( borderAll() ), actionCollection(),
"borderAll" );
- m_borderAll->setToolTip("Set a border around all cells in the selected area.");
+ m_borderAll->setToolTip(i18n("Set a border around all cells in the selected area."));
m_borderRemove = new KAction( i18n("Remove Borders"), "border_remove", 0,
this, SLOT( borderRemove() ), actionCollection(),
"borderRemove" );
- m_borderRemove->setToolTip("Remove all borders in the selected area.");
+ m_borderRemove->setToolTip(i18n("Remove all borders in the selected area."));
m_borderOutline = new KAction( i18n("Border Outline"), ("border_outline"), 0,
this, SLOT( borderOutline() ),
actionCollection(), "borderOutline" );
- m_borderOutline->setToolTip("Set a border to the outline of the selected area.");
+ m_borderOutline->setToolTip(i18n("Set a border to the outline of the selected area."));
m_borderColor = new TKSelectColorAction( i18n("Border Color"),
TKSelectColorAction::LineColor,
actionCollection(), "borderColor" );
connect(m_borderColor,SIGNAL(activated()),SLOT(changeBorderColor()));
- m_borderColor->setToolTip("Select a new border color.");
+ m_borderColor->setToolTip(i18n("Select a new border color."));
}
KSpreadView::~KSpreadView()
{
deleteEditor( true );
if ( !m_transformToolBox.isNull() )
delete (&*m_transformToolBox);
/*if(m_sbCalcLabel)
{
disconnect(m_sbCalcLabel,SIGNAL(pressed( int )),this,SLOT(statusBarClicked(int)));
}*/
if(m_spell.kspell)
{
delete m_spell.kspell;
}
m_pCanvas->endChoose();
m_pTable = 0; // set the active table to 0L so that when during destruction
// of embedded child documents possible repaints in KSpreadTable are not
// performed. The repains can happen if you delete an embedded document,
// which leads to an regionInvalidated() signal emission in KoView, which calls
// repaint, etc.etc. :-) (Simon)
delete m_pPopupColumn;
delete m_pPopupRow;
delete m_pPopupMenu;
delete m_popupChild;
delete m_popupListChoose;
delete m_sbCalcLabel;
delete m_dcop;
}
void KSpreadView::initConfig()
{
KConfig *config = KSpreadFactory::global()->config();
if( config->hasGroup("Parameters" ))
{
config->setGroup( "Parameters" );
m_pDoc->setShowHorizontalScrollBar(config->readBoolEntry("Horiz ScrollBar",true));
m_pDoc->setShowVerticalScrollBar(config->readBoolEntry("Vert ScrollBar",true));
m_pDoc->setShowColHeader(config->readBoolEntry("Column Header",true));
m_pDoc->setShowRowHeader(config->readBoolEntry("Row Header",true));
m_pDoc->setCompletionMode((KGlobalSettings::Completion)config->readNumEntry("Completion Mode",(int)(KGlobalSettings::CompletionAuto)));
m_pDoc->setMoveToValue((KSpread::MoveTo)config->readNumEntry("Move",(int)(KSpread::Bottom)));
m_pDoc->setIndentValue(config->readNumEntry( "Indent",10 ) );
m_pDoc->setTypeOfCalc((MethodOfCalc)config->readNumEntry("Method of Calc",(int)(SumOfNumber)));
m_pDoc->setShowTabBar(config->readBoolEntry("Tabbar",true));
m_pDoc->setShowMessageError(config->readBoolEntry( "Msg error" ,false) );
m_pDoc->setShowCommentIndicator(config->readBoolEntry("Comment Indicator",true));
m_pDoc->setShowFormulaBar(config->readBoolEntry("Formula bar",true));
m_pDoc->setShowStatusBar(config->readBoolEntry("Status bar",true));
changeNbOfRecentFiles(config->readNumEntry("NbRecentFile",10));
//autosave value is stored as a minute.
//but default value is stored as seconde.
m_pDoc->setAutoSave(config->readNumEntry("AutoSave",KoDocument::defaultAutoSave()/60)*60);
}
if( config->hasGroup("KSpread Color" ) )
{
config->setGroup( "KSpread Color" );
QColor _col(Qt::lightGray);
_col= config->readColorEntry("GridColor",&_col);
m_pDoc->changeDefaultGridPenColor(_col);
}
if( config->hasGroup("KSpread Page Layout" ) )
{
config->setGroup( "KSpread Page Layout" );
if( m_pDoc->isEmpty())
{
m_pDoc->setPaperFormat((KoFormat)config->readNumEntry("Default size page",1));
m_pDoc->setPaperOrientation((KoOrientation)config->readNumEntry("Default orientation page",0));
m_pDoc->setPaperUnit((KoUnit::Unit)config->readNumEntry("Default unit page",0));
}
}
initCalcMenu();
resultOfCalc();
}
void KSpreadView::changeNbOfRecentFiles(int _nb)
{
if(shell())
shell()->setMaxRecentItems( _nb );
}
void KSpreadView::initCalcMenu()
{
switch( doc()->getTypeOfCalc())
{
case SumOfNumber:
m_menuCalcSum->setChecked(true);
break;
case Min:
m_menuCalcMin->setChecked(true);
break;
case Max:
m_menuCalcMax->setChecked(true);
break;
case Average:
m_menuCalcAverage->setChecked(true);
break;
case Count:
m_menuCalcCount->setChecked(true);
break;
case NoneCalc:
m_menuCalcNone->setChecked(true);
break;
default :
m_menuCalcSum->setChecked(true);
break;
}
}
void KSpreadView::RecalcWorkBook(){
KSpreadTable *tbl;
for ( tbl = m_pDoc->map()->firstTable();
tbl != 0L;
tbl = m_pDoc->map()->nextTable() )
{
bool b = tbl->getAutoCalc();
tbl->setAutoCalc(true);
tbl->recalc();
tbl->setAutoCalc(b);
}
// slotUpdateView( activeTable() );
}
void KSpreadView::slotRefreshLocale()
{
kdDebug(36001)<<"KSpreadView::slotRefreshLocale()***************\n";
KSpreadTable *tbl;
for ( tbl = m_pDoc->map()->firstTable();
tbl != 0L;
tbl = m_pDoc->map()->nextTable() ){
tbl->updateLocale();
}
}
void KSpreadView::RecalcWorkSheet()
{
if (m_pTable != 0)
{
bool b = m_pTable->getAutoCalc();
m_pTable->setAutoCalc(true);
m_pTable->recalc();
m_pTable->setAutoCalc(b);
}
//slotUpdateView( activeTable() );
}
void KSpreadView::extraSpelling()
{
if (m_spell.kspell)
return; // Already in progress
if (m_pTable == 0L)
return;
// m_spell.macroCmdSpellCheck = 0L;
m_spell.firstSpellTable = m_pTable;
m_spell.currentSpellTable = m_spell.firstSpellTable;
QRect selection = m_pTable->selectionRect();
// if nothing is selected, check every cell
if (selection.left() == 0)
{
m_spell.spellStartCellX = 0;
m_spell.spellStartCellY = 0;
m_spell.spellEndCellX = 0;
m_spell.spellEndCellY = 0;
m_spell.spellCheckSelection = false;
m_spell.currentCell = m_pTable->firstCell();
}
else
{
m_spell.spellStartCellX = selection.left();
m_spell.spellStartCellY = selection.top();
m_spell.spellEndCellX = selection.right();
m_spell.spellEndCellY = selection.bottom();
m_spell.spellCheckSelection = true;
m_spell.currentCell = 0L;
// "-1" because X gets increased every time we go into spellCheckReady()
m_spell.spellCurrCellX = m_spell.spellStartCellX - 1;
m_spell.spellCurrCellY = m_spell.spellStartCellY;
}
startKSpell();
}
void KSpreadView::startKSpell()
{
m_spell.kspell = new KSpreadSpell( this, i18n( "Spell Checking" ), this,
SLOT( spellCheckerReady() ),
m_pDoc->getKSpellConfig() );
m_spell.ignoreWord = m_ignoreWord;
m_spell.kspell->ksConfig().setIgnoreList(m_spell.ignoreWord);
m_spell.kspell->setIgnoreUpperWords(m_pDoc->dontCheckUpperWord());
m_spell.kspell->setIgnoreTitleCase(m_pDoc->dontCheckTitleCase());
QObject::connect( m_spell.kspell, SIGNAL( death() ),
this, SLOT( spellCheckerFinished() ) );
QObject::connect( m_spell.kspell, SIGNAL( misspelling( const QString &,
const QStringList &,
unsigned int) ),
this, SLOT( spellCheckerMisspelling( const QString &,
const QStringList &,
unsigned int) ) );
QObject::connect( m_spell.kspell, SIGNAL( corrected( const QString &,
const QString &,
unsigned int) ),
this, SLOT( spellCheckerCorrected( const QString &,
const QString &,
unsigned int ) ) );
QObject::connect( m_spell.kspell, SIGNAL( done( const QString & ) ),
this, SLOT( spellCheckerDone( const QString & ) ) );
}
void KSpreadView::spellCheckerReady()
{
if (m_pCanvas)
m_pCanvas->setCursor( WaitCursor );
// go on to the next cell
if (!m_spell.spellCheckSelection)
{
// if nothing is selected we have to check every cell
// we use a different way to make it faster
while ( m_spell.currentCell )
{
// check text only
if ( !m_spell.currentCell->isDefault() && m_spell.currentCell->isString() )
{
m_spell.kspell->check( m_spell.currentCell->text(), true );
return;
}
m_spell.currentCell = m_spell.currentCell->nextCell();
}
if (spellSwitchToOtherTable())
spellCheckerReady();
else
spellCleanup();
return;
}
// if something is selected:
++m_spell.spellCurrCellX;
if (m_spell.spellCurrCellX > m_spell.spellEndCellX)
{
m_spell.spellCurrCellX = m_spell.spellStartCellX;
++m_spell.spellCurrCellY;
}
unsigned int y;
unsigned int x;
for ( y = m_spell.spellCurrCellY; y <= m_spell.spellEndCellY; ++y )
{
for ( x = m_spell.spellCurrCellX; x <= m_spell.spellEndCellX; ++x )
{
KSpreadCell * cell = m_spell.currentSpellTable->cellAt( x, y );
// check text only
if (cell->isDefault() || !cell->isString())
continue;
m_spell.spellCurrCellX = x;
m_spell.spellCurrCellY = y;
m_spell.kspell->check( cell->text(), true );
return;
}
m_spell.spellCurrCellX = m_spell.spellStartCellX;
}
// if the user selected something to be checked we are done
// otherwise ask for checking the next table if any
if (m_spell.spellCheckSelection)
{
// Done
spellCleanup();
}
else
{
if (spellSwitchToOtherTable())
spellCheckerReady();
else
spellCleanup();
}
}
void KSpreadView::spellCleanup()
{
if (m_pCanvas)
m_pCanvas->setCursor( ArrowCursor );
m_spell.kspell->cleanUp();
delete m_spell.kspell;
m_spell.kspell = 0L;
m_spell.firstSpellTable = 0L;
m_spell.currentSpellTable = 0L;
m_spell.currentCell = 0L;
KMessageBox::information( this, i18n( "Spell checking is complete." ) );
// not supported yet
// if(m_spell.macroCmdSpellCheck)
// m_pDoc->addCommand(m_spell.macroCmdSpellCheck);
}
bool KSpreadView::spellSwitchToOtherTable()
{
// there is no other table
if(m_pDoc->map()->count()==1)
return false;
// for optimization
QPtrList tableList = m_pDoc->map()->tableList();
unsigned int curIndex = tableList.findRef(m_spell.currentSpellTable);
++curIndex;
// last table? then start at the beginning
if ( curIndex >= tableList.count() )
m_spell.currentSpellTable = tableList.first();
else
m_spell.currentSpellTable = tableList.at(curIndex);
// if the current table is the first one again, we are done.
if( m_spell.currentSpellTable == m_spell.firstSpellTable )
{
setActiveTable( m_spell.firstSpellTable );
return false;
}
if (m_spell.spellCheckSelection)
{
m_spell.spellEndCellX = m_spell.currentSpellTable->maxColumn();
m_spell.spellEndCellY = m_spell.currentSpellTable->maxRow();
m_spell.spellCurrCellX = m_spell.spellStartCellX - 1;
m_spell.spellCurrCellY = m_spell.spellStartCellY;
}
else
{
m_spell.currentCell = m_spell.currentSpellTable->firstCell();
}
if ( KMessageBox::questionYesNo( this,
i18n( "Do you want to check the spelling in the next table?") )
!= KMessageBox::Yes )
return false;
setActiveTable(m_spell.currentSpellTable);
return true;
}
void KSpreadView::spellCheckerMisspelling( const QString &,
const QStringList &,
unsigned int )
{
// scroll to the cell
if (!m_spell.spellCheckSelection)
{
m_spell.spellCurrCellX = m_spell.currentCell->column();
m_spell.spellCurrCellY = m_spell.currentCell->row();
}
canvasWidget()->gotoLocation( m_spell.spellCurrCellX, m_spell.spellCurrCellY, activeTable() );
}
void KSpreadView::spellCheckerCorrected( const QString & old, const QString & corr,
unsigned int pos )
{
KSpreadCell * cell;
if (m_spell.spellCheckSelection)
{
cell = m_spell.currentSpellTable->cellAt( m_spell.spellCurrCellX,
m_spell.spellCurrCellY );
}
else
{
cell = m_spell.currentCell;
m_spell.spellCurrCellX = cell->column();
m_spell.spellCurrCellY = cell->row();
}
Q_ASSERT( cell );
if ( !cell )
return;
QString content( cell->text() );
KSpreadUndoSetText* undo = new KSpreadUndoSetText( m_pDoc, m_pTable,
content,
m_spell.spellCurrCellX,
m_spell.spellCurrCellY,
cell->formatType());
m_pDoc->undoBuffer()->appendUndo( undo );
content.replace( pos, old.length(), corr );
cell->setCellText( content );
m_pEditWidget->setText( content );
// TODO ?:
// if(!m_spell.macroCmdSpellCheck)
// m_spell.macroCmdSpellCheck=new KMacroCommand(i18n("Correct misspelled word"));
// m_spell.macroCmdSpellCheck->addCommand(textobj->textObject()->replaceSelectionCommand(&cursor, corr, KoTextObject::HighlightSelection, QString::null ));
}
void KSpreadView::spellCheckerDone( const QString & )
{
int result = m_spell.kspell->dlgResult();
// store ignore word
m_ignoreWord += m_spell.kspell->ksConfig().ignoreList();
m_spell.kspell->cleanUp();
delete m_spell.kspell;
m_spell.kspell = 0L;
if ( result != KS_CANCEL && result != KS_STOP )
{
if (m_spell.spellCheckSelection)
{
if ( (m_spell.spellCurrCellY <= m_spell.spellEndCellY)
&& (m_spell.spellCurrCellX <= m_spell.spellEndCellX) )
{
startKSpell();
return;
}
}
else
{
if ( m_spell.currentCell )
{
m_spell.currentCell = m_spell.currentCell->nextCell();
startKSpell();
return;
}
}
}
// Not implemented yet
// if(m_spell.macroCmdSpellCheck)
// m_pDoc->addCommand(m_spell.macroCmdSpellCheck);
}
void KSpreadView::spellCheckerFinished()
{
if (m_pCanvas)
m_pCanvas->setCursor( ArrowCursor );
KSpell::spellStatus status = m_spell.kspell->status();
m_spell.kspell->cleanUp();
delete m_spell.kspell;
m_spell.kspell = 0L;
bool kspellNotConfigured=false;
if (status == KSpell::Error)
{
KMessageBox::sorry(this, i18n("ISpell could not be started.\n"
"Please make sure you have ISpell properly configured and in your PATH."));
kspellNotConfigured=true;
}
else if (status == KSpell::Crashed)
{
KMessageBox::sorry(this, i18n("ISpell seems to have crashed."));
}
// Not implemented yet
// if(m_spell.macroCmdSpellCheck)
// m_pDoc->addCommand(m_spell.macroCmdSpellCheck);
if(kspellNotConfigured)
{
KSpreadpreference configDlg( this, 0 );
configDlg.openPage( KSpreadpreference::KS_SPELLING);
configDlg.exec();
}
}
void KSpreadView::initialPosition()
{
// Set the initial position for the marker as store in the XML file,
// (1,1) otherwise
int col = m_pDoc->map()->initialMarkerColumn();
if ( col <= 0 ) col = 1;
int row = m_pDoc->map()->initialMarkerRow();
if ( row <= 0 ) row = 1;
m_pCanvas->gotoLocation( col, row );
//init toggle button
updateBorderButton();
m_tableFormat->setEnabled(false);
m_mergeCell->setEnabled(false);
m_insertChartFrame->setEnabled(false);
// I don't think we should recalculate everything after loading, this takes much to much time
// and shouldn't be necessary at all - Philipp
//
// /*recalc all dependent after loading*/
// KSpreadTable *tbl;
// for ( tbl = m_pDoc->map()->firstTable(); tbl != 0L; tbl = m_pDoc->map()->nextTable() )
// {
// if( tbl->getAutoCalc() )
// tbl->recalc();
// tbl->refreshMergedCell();
// }
slotUpdateView( activeTable() );
m_bLoading =true;
if ( koDocument()->isReadWrite() )
initConfig();
}
void KSpreadView::updateEditWidgetOnPress()
{
int column = m_pCanvas->markerColumn();
int row = m_pCanvas->markerRow();
KSpreadCell* cell = m_pTable->cellAt( column, row );
if ( !cell )
{
editWidget()->setText( "" );
return;
}
if ( cell->content() == KSpreadCell::VisualFormula )
editWidget()->setText( "" );
else
editWidget()->setText( cell->text() );
}
void KSpreadView::updateEditWidget()
{
bool active=activeTable()->getShowFormula();
m_alignLeft->setEnabled(!active);
m_alignCenter->setEnabled(!active);
m_alignRight->setEnabled(!active);
m_toolbarLock = TRUE;
int column = m_pCanvas->markerColumn();
int row = m_pCanvas->markerRow();
KSpreadCell* cell = m_pTable->cellAt( column, row );
if ( !cell )
{
editWidget()->setText( "" );
return;
}
if ( cell->content() == KSpreadCell::VisualFormula )
{
editWidget()->setText( "" );
}
else
{
editWidget()->setText( cell->text() );
}
QColor color=cell->textColor( column, row );
if(!color.isValid())
color=QApplication::palette().active().text();
m_textColor->setCurrentColor( color );
color=cell->bgColor( column, row );
if(!color.isValid())
color=QApplication::palette().active().base();
m_bgColor->setCurrentColor( color );
m_selectFontSize->setFontSize( cell->textFontSize( column, row ) );
m_selectFont->setFont( cell->textFontFamily( column,row ) );
m_bold->setChecked( cell->textFontBold( column, row ) );
m_italic->setChecked( cell->textFontItalic( column, row) );
m_underline->setChecked( cell->textFontUnderline( column, row ) );
m_strikeOut->setChecked( cell->textFontStrike( column, row ) );
m_alignLeft->setChecked( cell->align( column, row ) == KSpreadLayout::Left );
m_alignCenter->setChecked( cell->align( column, row ) == KSpreadLayout::Center );
m_alignRight->setChecked( cell->align( column, row ) == KSpreadLayout::Right );
m_alignTop->setChecked( cell->alignY( column, row ) == KSpreadLayout::Top );
m_alignMiddle->setChecked( cell->alignY( column, row ) == KSpreadLayout::Middle );
m_alignBottom->setChecked( cell->alignY( column, row ) == KSpreadLayout::Bottom );
m_verticalText->setChecked( cell->verticalText( column,row ) );
m_multiRow->setChecked( cell->multiRow( column,row ) );
KSpreadCell::FormatType ft = cell->formatType();
m_percent->setChecked( ft == KSpreadCell::Percentage );
m_money->setChecked( ft == KSpreadCell::Money );
m_removeComment->setEnabled( !cell->comment(column,row).isEmpty() );
m_decreaseIndent->setEnabled(cell->getIndent(column,row)>0);
m_toolbarLock = FALSE;
if ( m_pCanvas->editor() )
{
m_pCanvas->editor()->setEditorFont(cell->textFont(column, row), true);
m_pCanvas->editor()->setFocus();
}
}
void KSpreadView::activateFormulaEditor()
{
}
void KSpreadView::updateReadWrite( bool readwrite )
{
#ifdef __GNUC_
#warning TODO
#endif
// m_pCancelButton->setEnabled( readwrite );
// m_pOkButton->setEnabled( readwrite );
m_pEditWidget->setEnabled( readwrite );
QValueList actions = actionCollection()->actions();
QValueList::ConstIterator aIt = actions.begin();
QValueList::ConstIterator aEnd = actions.end();
for (; aIt != aEnd; ++aIt )
(*aIt)->setEnabled( readwrite );
m_transform->setEnabled( false );
m_redo->setEnabled( false );
m_undo->setEnabled( false );
m_showTable->setEnabled( true );
m_hideTable->setEnabled( true );
m_gotoCell->setEnabled( true );
// m_newView->setEnabled( true );
//m_pDoc->KXMLGUIClient::action( "newView" )->setEnabled( true ); // obsolete (Werner)
// m_oszi->setEnabled( true );
}
void KSpreadView::tableFormat()
{
KSpreadFormatDlg dlg( this );
dlg.exec();
}
void KSpreadView::autoSum()
{
// ######## Torben: Make sure that this can not be called
// when canvas has a running editor
if ( m_pCanvas->editor() )
return;
m_pCanvas->createEditor( KSpreadCanvas::CellEditor );
m_pCanvas->editor()->setText( "=SUM()" );
m_pCanvas->editor()->setCursorPosition( 5 );
// Try to find numbers above
if ( m_pCanvas->markerRow() > 1 )
{
KSpreadCell* cell = 0;
int r = m_pCanvas->markerRow();
do
{
cell = activeTable()->cellAt( m_pCanvas->markerColumn(), --r );
}
while ( cell && cell->isNumeric() );
if ( r + 1 < m_pCanvas->markerRow() )
{
m_pTable->setChooseRect( QRect( m_pCanvas->markerColumn(), r + 1, 1, m_pCanvas->markerRow() - r - 1 ) );
return;
}
}
// Try to find numbers left
if ( m_pCanvas->markerColumn() > 1 )
{
KSpreadCell* cell = 0;
int c = m_pCanvas->markerColumn();
do
{
cell = activeTable()->cellAt( --c, m_pCanvas->markerRow() );
}
while ( cell && cell->isNumeric() );
if ( c + 1 < m_pCanvas->markerColumn() )
{
m_pTable->setChooseRect( QRect( c + 1, m_pCanvas->markerRow(), m_pCanvas->markerColumn() - c - 1, 1 ) );
return;
}
}
}
/*
void KSpreadView::oszilloscope()
{
QDialog* dlg = new KSpreadOsziDlg( this );
dlg->show();
}
*/
void KSpreadView::changeTextColor()
{
if ( m_pTable != 0L )
{
int col = m_pCanvas->markerColumn();
int row = m_pCanvas->markerRow();
m_pTable->setSelectionTextColor( QPoint( col, row ), m_textColor->color() );
}
}
void KSpreadView::changeBackgroundColor()
{
if ( m_pTable != 0L )
{
m_pTable->setSelectionbgColor( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), m_bgColor->color() );
}
}
void KSpreadView::changeBorderColor()
{
if ( m_pTable != 0L )
{
m_pTable->setSelectionBorderColor( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), m_borderColor->color() );
}
}
void KSpreadView::helpUsing()
{
kapp->invokeHelp( );
}
QButton * KSpreadView::newIconButton( const char *_file, bool _kbutton, QWidget *_parent )
{
if ( _parent == 0L )
_parent = this;
QButton *pb;
if ( !_kbutton )
pb = new QPushButton( _parent );
else
pb = new QToolButton( _parent );
pb->setPixmap( QPixmap( KSBarIcon(_file) ) );
return pb;
}
void KSpreadView::enableUndo( bool _b )
{
m_undo->setEnabled( _b );
m_undo->setText(i18n("Undo: %1").arg(m_pDoc->undoBuffer()->getUndoName()));
}
void KSpreadView::enableRedo( bool _b )
{
m_redo->setEnabled( _b );
m_redo->setText(i18n("Redo: %1").arg(m_pDoc->undoBuffer()->getRedoName()));
}
void KSpreadView::undo()
{
m_pDoc->undo();
updateEditWidget();
resultOfCalc();
}
void KSpreadView::redo()
{
m_pDoc->redo();
updateEditWidget();
resultOfCalc();
}
void KSpreadView::deleteColumn()
{
if ( !m_pTable )
return;
QRect r( activeTable()-> selectionRect() );
if( r.left()==0 || activeTable()->isRowSelected() )
m_pTable->removeColumn( m_pCanvas->markerColumn() );
else
m_pTable->removeColumn( r.left(),(r.right()-r.left()) );
updateEditWidget();
m_pTable->setSelection(m_pTable->marker());
}
void KSpreadView::deleteRow()
{
if ( !m_pTable )
return;
QRect r( activeTable()-> selectionRect() );
if( r.left()==0 || activeTable()->isColumnSelected() )
m_pTable->removeRow( m_pCanvas->markerRow() );
else
m_pTable->removeRow( r.top(),(r.bottom()-r.top()) );
updateEditWidget();
m_pTable->setSelection(m_pTable->marker());
}
void KSpreadView::insertColumn()
{
if ( !m_pTable )
return;
QRect r( activeTable()-> selectionRect() );
if( r.left()==0 || activeTable()->isRowSelected() )
m_pTable->insertColumn( m_pCanvas->markerColumn() );
else
m_pTable->insertColumn( r.left(),(r.right()-r.left()) );
updateEditWidget();
}
void KSpreadView::hideColumn()
{
if ( !m_pTable )
return;
QRect r( activeTable()-> selectionRect() );
if( r.left()==0 || activeTable()->isRowSelected() )
m_pTable->hideColumn( m_pCanvas->markerColumn() );
else
m_pTable->hideColumn( r.left(),(r.right()-r.left()) );
}
void KSpreadView::showColumn()
{
if ( !m_pTable )
return;
KSpreadShowColRow dlg( this,"showCol",KSpreadShowColRow::Column);
dlg.exec();
}
void KSpreadView::showSelColumns()
{
if ( !m_pTable )
return;
int i;
QRect rect = activeTable()->selectionRect();
ColumnLayout * col;
QValueListhiddenCols;
for ( i = rect.left(); i <= rect.right(); ++i )
{
if (i == 2) // "B"
{
col = activeTable()->columnLayout( 1 );
if ( col->isHide() )
{
hiddenCols.append( 1 );
}
}
col = m_pTable->columnLayout( i );
if ( col->isHide() )
{
hiddenCols.append(i);
}
}
if (hiddenCols.count() > 0)
m_pTable->showColumn(0, -1, hiddenCols);
}
void KSpreadView::insertRow()
{
if ( !m_pTable )
return;
QRect r( activeTable()-> selectionRect() );
if( r.left()==0 || activeTable()->isColumnSelected() )
m_pTable->insertRow( m_pCanvas->markerRow() );
else
m_pTable->insertRow( r.top(),(r.bottom()-r.top()) );
updateEditWidget();
}
void KSpreadView::hideRow()
{
if ( !m_pTable )
return;
QRect r( activeTable()-> selectionRect() );
if( r.left()==0 || activeTable()->isColumnSelected() )
m_pTable->hideRow( m_pCanvas->markerRow() );
else
m_pTable->hideRow( r.top(),(r.bottom()-r.top()) );
}
void KSpreadView::showRow()
{
if ( !m_pTable )
return;
KSpreadShowColRow dlg( this,"showRow",KSpreadShowColRow::Row);
dlg.exec();
}
void KSpreadView::showSelRows()
{
if ( !m_pTable )
return;
int i;
QRect rect = activeTable()->selectionRect();
RowLayout * row;
QValueListhiddenRows;
for ( i = rect.top(); i <= rect.bottom(); ++i )
{
if (i == 2)
{
row = activeTable()->rowLayout( 1 );
if ( row->isHide() )
{
hiddenRows.append(1);
}
}
row = m_pTable->rowLayout( i );
if ( row->isHide() )
{
hiddenRows.append(i);
}
}
if (hiddenRows.count() > 0)
m_pTable->showRow(0, -1, hiddenRows);
}
void KSpreadView::fontSelected( const QString &_font )
{
if ( m_toolbarLock )
return;
if ( m_pTable != 0L )
m_pTable->setSelectionFont( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), _font.latin1() );
// Dont leave the focus in the toolbars combo box ...
if ( m_pCanvas->editor() )
{
KSpreadCell * cell = m_pTable->cellAt( m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
m_pCanvas->editor()->setEditorFont(cell->textFont(cell->column(), cell->row()), true);
m_pCanvas->editor()->setFocus();
}
else
m_pCanvas->setFocus();
}
void KSpreadView::decreaseFontSize()
{
if( !m_pTable )
return;
m_pTable->setSelectionSize( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), -1 );
updateEditWidget();
}
void KSpreadView::increaseFontSize()
{
if( !m_pTable )
return;
m_pTable->setSelectionSize( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), 1 );
updateEditWidget();
}
void KSpreadView::lower()
{
if( !m_pTable )
return;
m_pTable->setSelectionUpperLower( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), -1 );
updateEditWidget();
}
void KSpreadView::upper()
{
if( !m_pTable )
return;
m_pTable->setSelectionUpperLower( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), 1 );
updateEditWidget();
}
void KSpreadView::firstLetterUpper()
{
if( !m_pTable )
return;
m_pTable->setSelectionfirstLetterUpper( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
updateEditWidget();
}
void KSpreadView::verticalText(bool b)
{
if( !m_pTable )
return;
m_pTable->setSelectionVerticalText( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ),b );
if( activeTable()->isRowSelected() == FALSE && activeTable()->isColumnSelected() == FALSE )
m_pCanvas->adjustArea(false);
updateEditWidget();
}
void KSpreadView::insertMathExpr()
{
if ( m_pTable == 0L )
return;
KSpreadDlgFormula *dlg=new KSpreadDlgFormula( this, "Formula Editor" );
dlg->exec();
// #### Is the dialog deleted when it's closed ? (David)
// Torben thinks that not.
}
void KSpreadView::formulaSelection( const QString &_math )
{
if ( m_pTable == 0 )
return;
if( _math == i18n("Others...") )
{
insertMathExpr();
return;
}
KSpreadDlgFormula *dlg=new KSpreadDlgFormula( this, "Formula Editor",_math );
dlg->exec();
}
void KSpreadView::fontSizeSelected( int _size )
{
if ( m_toolbarLock )
return;
if ( m_pTable != 0L )
m_pTable->setSelectionFont( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), 0L, _size );
// Dont leave the focus in the toolbars combo box ...
if ( m_pCanvas->editor() )
{
KSpreadCell * cell = m_pTable->cellAt( m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
m_pCanvas->editor()->setEditorFont(cell->textFont(m_pCanvas->markerColumn(), m_pCanvas->markerRow()), true);
m_pCanvas->editor()->setFocus();
}
else
m_pCanvas->setFocus();
}
void KSpreadView::bold( bool b )
{
if ( m_toolbarLock )
return;
if ( m_pTable == 0 )
return;
int col = m_pCanvas->markerColumn();
int row = m_pCanvas->markerRow();
m_pTable->setSelectionFont( QPoint( col, row ), 0L, -1, b );
if ( m_pCanvas->editor() )
{
KSpreadCell * cell = m_pTable->cellAt( col, row );
m_pCanvas->editor()->setEditorFont(cell->textFont(col, row), true);
}
}
void KSpreadView::underline( bool b )
{
if ( m_toolbarLock )
return;
if ( m_pTable == 0 )
return;
int col = m_pCanvas->markerColumn();
int row = m_pCanvas->markerRow();
m_pTable->setSelectionFont( QPoint( col, row ), 0L, -1, -1, -1 ,b );
if ( m_pCanvas->editor() )
{
KSpreadCell * cell = m_pTable->cellAt( col, row );
m_pCanvas->editor()->setEditorFont(cell->textFont(col, row), true);
}
}
void KSpreadView::strikeOut( bool b )
{
if ( m_toolbarLock )
return;
if ( m_pTable == 0 )
return;
int col = m_pCanvas->markerColumn();
int row = m_pCanvas->markerRow();
m_pTable->setSelectionFont( QPoint( col, row ), 0L, -1, -1, -1 ,-1,b );
if ( m_pCanvas->editor() )
{
KSpreadCell * cell = m_pTable->cellAt( col, row );
m_pCanvas->editor()->setEditorFont(cell->textFont(col, row), true);
}
}
void KSpreadView::italic( bool b )
{
if ( m_toolbarLock )
return;
if ( m_pTable == 0 )
return;
int col = m_pCanvas->markerColumn();
int row = m_pCanvas->markerRow();
m_pTable->setSelectionFont( QPoint( col, row ), 0L, -1, -1, b );
if ( m_pCanvas->editor() )
{
KSpreadCell * cell = m_pTable->cellAt( col, row );
m_pCanvas->editor()->setEditorFont(cell->textFont(col, row), true);
}
}
void KSpreadView::sortInc()
{
QRect r( activeTable()-> selectionRect() );
if ( r.left() == 0 || r.top() == 0 ||
r.right() == 0 || r.bottom() == 0 )
{
KMessageBox::error( this, i18n("You must select multiple cells.") );
return;
}
// Entire row(s) selected ? Or just one row ?
if( activeTable()->isRowSelected() || r.top() == r.bottom() )
activeTable()->sortByRow( r.top(), KSpreadTable::Increase );
else
activeTable()->sortByColumn( r.left(), KSpreadTable::Increase );
updateEditWidget();
}
void KSpreadView::sortDec()
{
QRect r( activeTable()-> selectionRect() );
if ( r.left() == 0 || r.top() == 0 ||
r.right() == 0 || r.bottom() == 0 )
{
KMessageBox::error( this, i18n("You must select multiple cells.") );
return;
}
// Entire row(s) selected ? Or just one row ?
if( activeTable()->isRowSelected() || r.top() == r.bottom() )
activeTable()->sortByRow( r.top(), KSpreadTable::Decrease );
else
activeTable()->sortByColumn( r.left(), KSpreadTable::Decrease );
updateEditWidget();
}
void KSpreadView::reloadScripts()
{
// TODO
}
void KSpreadView::runLocalScript()
{
// TODO
}
void KSpreadView::editGlobalScripts()
{
if ( KSpreadView::m_pGlobalScriptsDialog == 0L )
KSpreadView::m_pGlobalScriptsDialog = new KSpreadScripts();
KSpreadView::m_pGlobalScriptsDialog->show();
KSpreadView::m_pGlobalScriptsDialog->raise();
}
void KSpreadView::editLocalScripts()
{
// TODO
/* if ( !m_pDoc->editPythonCode() )
{
KMessageBox::error( i18n( "Could not start editor" ) );
return;
} */
}
void KSpreadView::borderBottom()
{
if ( m_pTable != 0L )
m_pTable->borderBottom( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) ,m_borderColor->color());
}
void KSpreadView::borderRight()
{
if ( m_pTable != 0L )
m_pTable->borderRight( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) ,m_borderColor->color());
}
void KSpreadView::borderLeft()
{
if ( m_pTable != 0L )
m_pTable->borderLeft( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ),m_borderColor->color() );
}
void KSpreadView::borderTop()
{
if ( m_pTable != 0L )
m_pTable->borderTop( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ),m_borderColor->color() );
}
void KSpreadView::borderOutline()
{
if ( m_pTable != 0L )
m_pTable->borderOutline( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) ,m_borderColor->color());
}
void KSpreadView::borderAll()
{
if ( m_pTable != 0L )
m_pTable->borderAll( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ),m_borderColor->color() );
}
void KSpreadView::borderRemove()
{
if ( m_pTable != 0L )
m_pTable->borderRemove( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
}
void KSpreadView::addTable( KSpreadTable *_t )
{
if( !_t->isHidden() )
{
m_pTabBar->addTab( _t->tableName() );
setActiveTable( _t );
}
else
{
m_pTabBar->addHiddenTab(_t->tableName());
}
// Connect some signals
QObject::connect( _t, SIGNAL( sig_updateView( KSpreadTable* ) ), SLOT( slotUpdateView( KSpreadTable* ) ) );
QObject::connect( _t, SIGNAL( sig_updateView( KSpreadTable *, const QRect& ) ),
SLOT( slotUpdateView( KSpreadTable*, const QRect& ) ) );
QObject::connect( _t, SIGNAL( sig_unselect( KSpreadTable *, const QRect& ) ),
SLOT( slotUnselect( KSpreadTable *, const QRect& ) ) );
QObject::connect( _t, SIGNAL( sig_updateHBorder( KSpreadTable * ) ),
SLOT( slotUpdateHBorder( KSpreadTable * ) ) );
QObject::connect( _t, SIGNAL( sig_updateVBorder( KSpreadTable * ) ),
SLOT( slotUpdateVBorder( KSpreadTable * ) ) );
QObject::connect( _t, SIGNAL( sig_changeSelection( KSpreadTable *, const QRect &, const QRect & ) ),
SLOT( slotChangeSelection( KSpreadTable *, const QRect &, const QRect & ) ) );
QObject::connect( _t, SIGNAL( sig_changeChooseSelection( KSpreadTable *, const QRect &, const QRect & ) ),
SLOT( slotChangeChooseSelection( KSpreadTable *, const QRect &, const QRect & ) ) );
QObject::connect( _t, SIGNAL( sig_nameChanged( KSpreadTable*, const QString& ) ),
this, SLOT( slotTableRenamed( KSpreadTable*, const QString& ) ) );
QObject::connect( _t, SIGNAL( sig_TableHidden( KSpreadTable* ) ),
this, SLOT( slotTableHidden( KSpreadTable* ) ) );
QObject::connect( _t, SIGNAL( sig_TableShown( KSpreadTable* ) ),
this, SLOT( slotTableShown( KSpreadTable* ) ) );
QObject::connect( _t, SIGNAL( sig_TableRemoved( KSpreadTable* ) ),
this, SLOT( slotTableRemoved( KSpreadTable* ) ) );
QObject::connect( _t, SIGNAL( sig_TableActivated( KSpreadTable* ) ),
this, SLOT( slotTableActivated( KSpreadTable* ) ) );
// ########### Why do these signals not send a pointer to the table?
// This will lead to bugs.
QObject::connect( _t, SIGNAL( sig_updateChildGeometry( KSpreadChild* ) ),
SLOT( slotUpdateChildGeometry( KSpreadChild* ) ) );
QObject::connect( _t, SIGNAL( sig_removeChild( KSpreadChild* ) ), SLOT( slotRemoveChild( KSpreadChild* ) ) );
QObject::connect( _t, SIGNAL( sig_maxColumn( int ) ), m_pCanvas, SLOT( slotMaxColumn( int ) ) );
QObject::connect( _t, SIGNAL( sig_maxRow( int ) ), m_pCanvas, SLOT( slotMaxRow( int ) ) );
QObject::connect( _t, SIGNAL( sig_polygonInvalidated( const QPointArray& ) ),
this, SLOT( repaintPolygon( const QPointArray& ) ) );
if(m_bLoading)
updateBorderButton();
}
void KSpreadView::slotTableRemoved( KSpreadTable *_t )
{
QString m_tableName=_t->tableName();
m_pTabBar->removeTab( _t->tableName() );
if(m_pDoc->map()->findTable( m_pTabBar->listshow().first()))
setActiveTable( m_pDoc->map()->findTable( m_pTabBar->listshow().first() ));
else
m_pTable = 0L;
QValueList::Iterator it;
QValueList area=doc()->listArea();
for ( it = area.begin(); it != area.end(); ++it )
{
//remove Area Name when table target is removed
if((*it).table_name==m_tableName)
{
doc()->removeArea((*it).ref_name);
//now area name is used in formula
//so you must recalc tables when remove areaname
KSpreadTable *tbl;
for ( tbl = doc()->map()->firstTable(); tbl != 0L; tbl = doc()->map()->nextTable() )
{
tbl->refreshRemoveAreaName((*it).ref_name);
}
}
}
m_pHorzScrollBar->setValue(activeTable()->getScrollPosX());
m_pVertScrollBar->setValue(activeTable()->getScrollPosY());
}
void KSpreadView::removeAllTables()
{
m_pTabBar->removeAllTabs();
setActiveTable( 0L );
}
void KSpreadView::setActiveTable( KSpreadTable *_t,bool updateTable )
{
if ( _t == m_pTable )
return;
m_pTable = _t;
if ( m_pTable == 0L )
return;
if(updateTable)
{
m_pTabBar->setActiveTab( _t->tableName() );
m_pVBorderWidget->repaint();
m_pHBorderWidget->repaint();
m_pCanvas->repaint();
m_pCanvas->slotMaxColumn( m_pTable->maxColumn() );
m_pCanvas->slotMaxRow( m_pTable->maxRow() );
}
resultOfCalc();
}
void KSpreadView::slotRefreshView( )
{
refreshView();
}
void KSpreadView::slotTableActivated( KSpreadTable* table )
{
m_pTabBar->setActiveTab( table->tableName() );
}
void KSpreadView::slotTableRenamed( KSpreadTable* table, const QString& old_name )
{
m_pTabBar->renameTab( old_name, table->tableName() );
}
void KSpreadView::slotTableHidden( KSpreadTable* table )
{
m_pTabBar->hideTable( table->tableName() );
}
void KSpreadView::slotTableShown( KSpreadTable* table )
{
m_pTabBar->displayTable( table->tableName() );
}
void KSpreadView::changeTable( const QString& _name )
{
if ( activeTable()->tableName() == _name )
return;
KSpreadTable *t = m_pDoc->map()->findTable( _name );
if ( !t )
{
kdDebug(36001) << "Unknown table " << _name << endl;
return;
}
m_pCanvas->closeEditor();
activeTable()->setScrollPosX(m_pHorzScrollBar->value());
activeTable()->setScrollPosY(m_pVertScrollBar->value());
setActiveTable( t,false );
t->setActiveTable();
updateEditWidget();
m_pHorzScrollBar->setValue(t->getScrollPosX());
m_pVertScrollBar->setValue(t->getScrollPosY());
//refresh toggle button
updateBorderButton();
}
void KSpreadView::slotScrollToFirstTable()
{
m_pTabBar->scrollFirst();
}
void KSpreadView::slotScrollToLeftTable()
{
m_pTabBar->scrollLeft();
}
void KSpreadView::slotScrollToRightTable()
{
m_pTabBar->scrollRight();
}
void KSpreadView::slotScrollToLastTable()
{
m_pTabBar->scrollLast();
}
void KSpreadView::insertTable()
{
m_pCanvas->closeEditor();
activeTable()->setScrollPosX(m_pHorzScrollBar->value());
activeTable()->setScrollPosY(m_pVertScrollBar->value());
KSpreadTable *t = m_pDoc->createTable();
m_pDoc->addTable( t );
m_pHorzScrollBar->setValue(t->getScrollPosX());
m_pVertScrollBar->setValue(t->getScrollPosY());
updateEditWidget();
}
void KSpreadView::hideTable()
{
if ( !m_pTable )
return;
m_pTabBar->hideTable();
}
void KSpreadView::showTable()
{
if ( !m_pTable )
return;
KSpreadshow dlg( this, "Table show");
dlg.exec();
}
void KSpreadView::copySelection()
{
if ( !m_pTable )
return;
if(!m_pCanvas->editor())
{
m_pTable->copySelection( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
updateEditWidget();
}
else
m_pCanvas->editor()->copy();
}
void KSpreadView::copyAsText()
{
if ( !m_pTable )
return;
m_pTable->copyAsText( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
}
void KSpreadView::cutSelection()
{
if ( !m_pTable )
return;
//don't used this function when we edit a cell.
if( !m_pCanvas->editor())
{
m_pTable->cutSelection( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
resultOfCalc();
updateEditWidget();
}
else
m_pCanvas->editor()->cut();
}
void KSpreadView::paste()
{
if ( !m_pTable )
return;
if( !m_pCanvas->editor() )
{
QRect r( activeTable()-> selectionRect() );
if( r.left()==0 )
r.setCoords( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ,
m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
m_pTable->paste( QPoint( r.left(), r.top() ) );
if( m_pTable->getAutoCalc() )
m_pTable->recalc();
resultOfCalc();
updateEditWidget();
}
else
{
m_pCanvas->editor()->paste();
}
}
void KSpreadView::specialPaste()
{
if ( !m_pTable )
return;
KSpreadspecial dlg( this, "Special Paste" );
if( dlg.exec() )
{
if (m_pTable->getAutoCalc())
m_pTable->recalc();
resultOfCalc();
updateEditWidget();
}
}
void KSpreadView::removeComment()
{
if ( !m_pTable )
return;
m_pTable->setSelectionRemoveComment( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
updateEditWidget();
}
void KSpreadView::changeAngle()
{
if ( !m_pTable )
return;
KSpreadAngle dlg( this, "Angle" ,QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ));
if(dlg.exec())
{
if( (activeTable()->isRowSelected() == FALSE) && (activeTable()->isColumnSelected() == FALSE) )
m_pCanvas->adjustArea(false);
}
}
void KSpreadView::mergeCell()
{
if ( !m_pTable )
return;
if((activeTable()->isRowSelected()) ||(activeTable()->isColumnSelected()))
{
KMessageBox::error( this, i18n("Area too large!"));
}
else
{
m_pTable->mergeCell( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
}
}
void KSpreadView::dissociateCell()
{
if ( !m_pTable )
return;
m_pTable->dissociateCell( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
}
void KSpreadView::increaseIndent()
{
if ( !m_pTable )
return;
m_pTable->increaseIndent( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
updateEditWidget();
}
void KSpreadView::decreaseIndent()
{
if ( !m_pTable )
return;
int column=m_pCanvas->markerColumn();
int row=m_pCanvas->markerRow();
m_pTable->decreaseIndent( QPoint( column, row ) );
KSpreadCell* cell = m_pTable->cellAt( column, row );
if(cell)
m_decreaseIndent->setEnabled(cell->getIndent(column,row)>0);
}
void KSpreadView::consolidate()
{
- if ( m_pCanvas->editor() )
- {
- m_pCanvas->deleteEditor( true ); // save changes
- }
- KSpreadConsolidate *dlg=new KSpreadConsolidate( this, "Consolidate" );
- dlg->show();
+ if ( m_pCanvas->editor() )
+ {
+ m_pCanvas->deleteEditor( true ); // save changes
+ }
+ KSpreadConsolidate dlg( this, "Consolidate" );
+ dlg.exec();
}
void KSpreadView::sortList()
{
KSpreadList dlg(this,"List selection");
dlg.exec();
}
void KSpreadView::gotoCell()
{
KSpreadGotoDlg dlg( this, "GotoCell" );
dlg.exec();
}
void KSpreadView::find()
{
KoFindDialog dlg( this, "Find", m_findOptions, m_findStrings );
if ( KoFindDialog::Accepted != dlg.exec() )
{
return;
}
m_findOptions = dlg.options();
m_findStrings = dlg.findHistory();
// Do the finding!
QPoint m_marker=QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
activeTable()->find( m_marker, dlg.pattern(), dlg.options(), m_pCanvas );
}
void KSpreadView::replace()
{
KoReplaceDialog dlg( this, "Replace", m_findOptions, m_findStrings, m_replaceStrings );
if ( KoReplaceDialog::Accepted != dlg.exec() )
{
return;
}
m_findOptions = dlg.options();
m_findStrings = dlg.findHistory();
m_replaceStrings = dlg.replacementHistory();
// Do the replacement.
QPoint m_marker=QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
activeTable()->replace( m_marker, dlg.pattern(), dlg.replacement(), dlg.options(), m_pCanvas );
// Refresh the editWidget
KSpreadCell *cell = activeTable()->cellAt( canvasWidget()->markerColumn(),
canvasWidget()->markerRow() );
if ( cell->text() != 0L )
editWidget()->setText( cell->text() );
else
editWidget()->setText( "" );
}
void KSpreadView::conditional()
{
QRect rect( activeTable()-> selectionRect() );
if( (activeTable()->isRowSelected()) || (activeTable()->isColumnSelected()) )
{
KMessageBox::error( this, i18n("Area too large!"));
}
else
{
if ( rect.left() == 0 || rect.top() == 0 ||
rect.right() == 0 || rect.bottom() == 0 )
{
rect.setCoords( m_pCanvas->markerColumn(), m_pCanvas->markerRow(),m_pCanvas->markerColumn(), m_pCanvas->markerRow());
}
KSpreadconditional dlg(this,"conditional",rect);
dlg.exec();
}
}
void KSpreadView::validity()
{
QRect rect( activeTable()-> selectionRect() );
if( (activeTable()->isRowSelected()) || (activeTable()->isColumnSelected()) )
{
KMessageBox::error( this, i18n("Area too large!"));
}
else
{
if ( rect.left() == 0 || rect.top() == 0 ||
rect.right() == 0 || rect.bottom() == 0 )
{
rect.setCoords( m_pCanvas->markerColumn(), m_pCanvas->markerRow(),m_pCanvas->markerColumn(), m_pCanvas->markerRow());
}
KSpreadDlgValidity dlg( this,"validity",rect);
dlg.exec();
}
}
void KSpreadView::insertSeries()
{
KSpreadSeriesDlg dlg( this, "Series", QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
dlg.exec();
}
void KSpreadView::sort()
{
QRect selection( m_pTable->selectionRect() );
if(selection.left()==0)
{
KMessageBox::error( this, i18n("You must select multiple cells") );
return;
}
KSpreadSortDlg dlg( this, "Sort" );
dlg.exec();
}
void KSpreadView::insertHyperlink()
{
KSpreadLinkDlg dlg( this, "Create Hyperlink" );
dlg.exec();
}
void KSpreadView::setupPrinter( KPrinter &prt )
{
//apply page layout parameters
KoFormat pageFormat = m_pDoc->paperFormat();
prt.setPageSize( static_cast( KoPageFormat::printerPageSize( pageFormat ) ) );
if ( m_pDoc->orientation() == PG_LANDSCAPE || pageFormat == PG_SCREEN )
prt.setOrientation( KPrinter::Landscape );
else
prt.setOrientation( KPrinter::Portrait );
}
+void KSpreadView::insertFromDatabase()
+{
+ if ( m_pCanvas->editor() )
+ {
+ m_pCanvas->deleteEditor( true ); // save changes
+ }
+
+ QRect rect = activeTable()->selectionRect();
+
+ if (rect.left() <= 0)
+ {
+ rect.setLeft( m_pCanvas->markerColumn() );
+ rect.setRight( m_pCanvas->markerColumn() );
+ rect.setTop( m_pCanvas->markerRow() );
+ rect.setBottom( m_pCanvas->markerRow() );
+ }
+
+ KSpreadDatabaseDlg dlg(this, rect, "KSpreadDatabaseDlg");
+ dlg.exec();
+}
+
+void KSpreadView::insertFromTextfile()
+{
+ if ( m_pCanvas->editor() )
+ {
+ m_pCanvas->deleteEditor( true ); // save changes
+ }
+
+ QRect rect = activeTable()->selectionRect();
+
+ if (rect.left() <= 0)
+ {
+ rect.setLeft( m_pCanvas->markerColumn() );
+ rect.setRight( m_pCanvas->markerColumn() );
+ rect.setTop( m_pCanvas->markerRow() );
+ rect.setBottom( m_pCanvas->markerRow() );
+ }
+
+ KMessageBox::information( this, "Not implemented yet, work in progress...");
+
+ // KSpreadTextfileDlg dlg(this, rect, "KSpreadDatabaseDlg");
+ // dlg.exec();
+}
+
+void KSpreadView::insertFromClipboard()
+{
+ if ( m_pCanvas->editor() )
+ {
+ m_pCanvas->deleteEditor( true ); // save changes
+ }
+
+ QRect rect = activeTable()->selectionRect();
+
+ if (rect.left() <= 0)
+ {
+ rect.setLeft( m_pCanvas->markerColumn() );
+ rect.setRight( m_pCanvas->markerColumn() );
+ rect.setTop( m_pCanvas->markerRow() );
+ rect.setBottom( m_pCanvas->markerRow() );
+ }
+
+ KMessageBox::information( this, "Not implemented yet, work in progress...");
+
+ // KSpreadClipboard dlg(this, rect, "KSpreadDatabaseDlg");
+ // dlg.exec();
+}
+
void KSpreadView::print( KPrinter &prt )
{
//store the current setting in a temporary variable
KoOrientation _orient = m_pDoc->orientation();
//use the current orientation from print dialog
if ( prt.orientation() == KPrinter::Landscape )
m_pDoc->setPaperOrientation( PG_LANDSCAPE );
else
m_pDoc->setPaperOrientation( PG_PORTRAIT );
prt.setFullPage( TRUE );
prt.setResolution ( 72 );
QPainter painter;
painter.begin( &prt );
// Print the table and tell that m_pDoc is NOT embedded.
m_pTable->print( painter, &prt );
painter.end();
//Restore original orientation
m_pDoc->setPaperOrientation( _orient );
}
void KSpreadView::insertChart( const QRect& _geometry, KoDocumentEntry& _e )
{
if ( !m_pTable )
return;
// Transform the view coordinates to document coordinates
QWMatrix m = matrix().invert();
QPoint tl = m.map( _geometry.topLeft() );
QPoint br = m.map( _geometry.bottomRight() );
if( (activeTable()->isRowSelected()) || (activeTable()->isColumnSelected()) )
{
KMessageBox::error( this, i18n("Area too large!"));
m_pTable->insertChart( QRect( tl, br ), _e, QRect( m_pCanvas->markerColumn(), m_pCanvas->markerRow(),1,1) );
}
else
{
// Insert the new child in the active table.
m_pTable->insertChart( QRect( tl, br ), _e, m_pTable->selectionRect() );
}
}
void KSpreadView::insertChild( const QRect& _geometry, KoDocumentEntry& _e )
{
if ( !m_pTable )
return;
// Transform the view coordinates to document coordinates
QWMatrix m = matrix().invert();
QPoint tl = m.map( _geometry.topLeft() );
QPoint br = m.map( _geometry.bottomRight() );
// Insert the new child in the active table.
m_pTable->insertChild( QRect( tl, br ), _e );
}
void KSpreadView::slotRemoveChild( KSpreadChild *_child )
{
if ( _child->table() != m_pTable )
return;
// Make shure that this child has no active embedded view -> activate ourselfs
partManager()->setActivePart( koDocument(), this );
partManager()->setSelectedPart( 0 );
}
void KSpreadView::slotUpdateChildGeometry( KSpreadChild */*_child*/ )
{
// ##############
// TODO
/*
if ( _child->table() != m_pTable )
return;
// Find frame for child
KSpreadChildFrame *f = 0L;
QPtrListIterator it( m_lstFrames );
for ( ; it.current() && !f; ++it )
if ( it.current()->child() == _child )
f = it.current();
assert( f != 0L );
// Are we already up to date ?
if ( _child->geometry() == f->partGeometry() )
return;
// TODO zooming
f->setPartGeometry( _child->geometry() );
*/
}
void KSpreadView::togglePageBorders( bool mode )
{
if ( !m_pTable )
return;
m_pTable->setShowPageBorders( mode );
}
void KSpreadView::preference()
{
if ( !m_pTable )
return;
KSpreadpreference dlg( this, "Preference");
if(dlg.exec())
m_pTable->refreshPreference();
}
void KSpreadView::addModifyComment()
{
if ( !m_pTable )
return;
KSpreadComment dlg( this, "comment",QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ));
if(dlg.exec())
updateEditWidget();
}
void KSpreadView::editCell()
{
if ( m_pCanvas->editor() )
return;
m_pCanvas->createEditor();
}
void KSpreadView::nextTable(){
KSpreadTable *t = m_pDoc->map()->nextTable( activeTable() );
if ( !t )
{
kdDebug(36001) << "Unknown table " << endl;
return;
}
m_pCanvas->closeEditor();
activeTable()->setScrollPosX(m_pHorzScrollBar->value());
activeTable()->setScrollPosY(m_pVertScrollBar->value());
setActiveTable( t,false );
t->setActiveTable();
}
void KSpreadView::previousTable(){
KSpreadTable *t = m_pDoc->map()->previousTable( activeTable() );
if ( !t )
{
kdDebug(36001) << "Unknown table " << endl;
return;
}
m_pCanvas->closeEditor();
activeTable()->setScrollPosX(m_pHorzScrollBar->value());
activeTable()->setScrollPosY(m_pVertScrollBar->value());
setActiveTable( t,false );
t->setActiveTable();
}
void KSpreadView::firstTable(){
KSpreadTable *t = m_pDoc->map()->firstTable();
if ( !t )
{
kdDebug(36001) << "Unknown table " << endl;
return;
}
m_pCanvas->closeEditor();
activeTable()->setScrollPosX(m_pHorzScrollBar->value());
activeTable()->setScrollPosY(m_pVertScrollBar->value());
setActiveTable( t,false );
t->setActiveTable();
}
void KSpreadView::lastTable(){
KSpreadTable *t = m_pDoc->map()->lastTable( );
if ( !t )
{
kdDebug(36001) << "Unknown table " << endl;
return;
}
m_pCanvas->closeEditor();
activeTable()->setScrollPosX(m_pHorzScrollBar->value());
activeTable()->setScrollPosY(m_pVertScrollBar->value());
setActiveTable( t,false );
t->setActiveTable();
}
void KSpreadView::keyPressEvent ( QKeyEvent* _ev )
{
// Dont eat accelerators
if ( _ev->state() & ( Qt::AltButton | Qt::ControlButton ) ){
if ( _ev->state() & ( Qt::ControlButton ) ){
switch( _ev->key() ){
#ifndef NDEBUG
case Key_V: // Ctrl+Shift+V to show debug (similar to KWord)
if ( _ev->state() & Qt::ShiftButton )
m_pTable->printDebug();
#endif
default:
QWidget::keyPressEvent( _ev );
return;
}
}
QWidget::keyPressEvent( _ev );
}
else
QApplication::sendEvent( m_pCanvas, _ev );
}
KoDocument* KSpreadView::hitTest( const QPoint &pos )
{
// Code copied from KoView::hitTest
KoViewChild *viewChild;
QWMatrix m = matrix();
m.translate( m_pCanvas->xOffset(), m_pCanvas->yOffset() );
KoDocumentChild *docChild = selectedChild();
if ( docChild )
{
if ( ( viewChild = child( docChild->document() ) ) )
{
if ( viewChild->frameRegion( m ).contains( pos ) )
return 0;
}
else
if ( docChild->frameRegion( m ).contains( pos ) )
return 0;
}
docChild = activeChild();
if ( docChild )
{
if ( ( viewChild = child( docChild->document() ) ) )
{
if ( viewChild->frameRegion( m ).contains( pos ) )
return 0;
}
else
if ( docChild->frameRegion( m ).contains( pos ) )
return 0;
}
QPoint pos2( int(pos.x() / zoom()), int(pos.y() / zoom()) );
QPtrListIterator it( m_pDoc->children() );
for (; it.current(); ++it )
{
// Is the child document on the visible table ?
if ( ((KSpreadChild*)it.current())->table() == m_pTable )
{
KoDocument *doc = it.current()->hitTest( pos2, m );
if ( doc )
return doc;
}
}
return m_pDoc;
}
int KSpreadView::leftBorder() const
{
return YBORDER_WIDTH;
}
int KSpreadView::rightBorder() const
{
return m_pVertScrollBar->width();
}
int KSpreadView::topBorder() const
{
return m_pToolWidget->height() + XBORDER_HEIGHT;
}
int KSpreadView::bottomBorder() const
{
return m_pHorzScrollBar->height();
}
void KSpreadView::refreshView()
{
bool active=activeTable()->getShowFormula();
m_alignLeft->setEnabled(!active);
m_alignCenter->setEnabled(!active);
m_alignRight->setEnabled(!active);
active=m_pDoc->getShowFormulaBar();
editWidget()->showEditWidget(active);
int posFrame=30;
if(active)
posWidget()->show();
else
{
posWidget()->hide();
posFrame=0;
}
m_pToolWidget->show();
// If this value (30) is changed then topBorder() needs to
// be changed, too.
m_pToolWidget->setGeometry( 0, 0, width(), /*30*/posFrame );
int top = /*30*/posFrame;
if(m_pDoc->getShowTabBar())
{
m_pTabBarFirst->setGeometry( 0, height() - 16, 16, 16 );
m_pTabBarLeft->setGeometry( 16, height() - 16, 16, 16 );
m_pTabBarRight->setGeometry( 32, height() - 16, 16, 16 );
m_pTabBarLast->setGeometry( 48, height() - 16, 16, 16 );
m_pTabBarFirst->show();
m_pTabBarLeft->show();
m_pTabBarRight->show();
m_pTabBarLast->show();
}
else
{
m_pTabBarFirst->hide();
m_pTabBarLeft->hide();
m_pTabBarRight->hide();
m_pTabBarLast->hide();
}
if(!m_pDoc->getShowHorizontalScrollBar())
m_pTabBar->setGeometry( 64, height() - 16, width() -64, 16 );
else
m_pTabBar->setGeometry( 64, height() - 16, width() / 2 - 64, 16 );
if(m_pDoc->getShowTabBar())
m_pTabBar->show();
else
m_pTabBar->hide();
// David's suggestion: move the scrollbars to KSpreadCanvas, but keep those resize statements
int widthScrollbarVertical=16;
if(m_pDoc->getShowHorizontalScrollBar())
m_pHorzScrollBar->show();
else
m_pHorzScrollBar->hide();
if(!m_pDoc->getShowTabBar() && !m_pDoc->getShowHorizontalScrollBar())
m_pVertScrollBar->setGeometry( width() - 16, top , 15, height() - top );
else
m_pVertScrollBar->setGeometry( width() - 16, top , 15, height() - 16 - top );
m_pVertScrollBar->setSteps( 20 /*linestep*/, m_pVertScrollBar->height() /*pagestep*/);
if(m_pDoc->getShowVerticalScrollBar())
m_pVertScrollBar->show();
else
{
widthScrollbarVertical=0;
m_pVertScrollBar->hide();
}
int widthRowHeader=YBORDER_WIDTH;
if(m_pDoc->getShowRowHeader())
m_pVBorderWidget->show();
else
{
widthRowHeader=0;
m_pVBorderWidget->hide();
}
int heightColHeader=XBORDER_HEIGHT;
if(m_pDoc->getShowColHeader())
m_pHBorderWidget->show();
else
{
heightColHeader=0;
m_pHBorderWidget->hide();
}
if(statusBar())
{
if(m_pDoc->getShowStatusBar())
statusBar()->show();
else
statusBar()->hide();
}
m_pHorzScrollBar->setGeometry( width() / 2, height() - 16, width() / 2 - widthScrollbarVertical, 15 );
m_pHorzScrollBar->setSteps( 20 /*linestep*/, m_pHorzScrollBar->width() /*pagestep*/);
if(!m_pDoc->getShowTabBar() && !m_pDoc->getShowHorizontalScrollBar())
m_pFrame->setGeometry( 0, top, width()-widthScrollbarVertical, height() - top );
else
m_pFrame->setGeometry( 0, top, width()-widthScrollbarVertical, height() -16 - top );
m_pFrame->show();
m_pCanvas->setGeometry( widthRowHeader, heightColHeader,
m_pFrame->width() -widthRowHeader, m_pFrame->height() - heightColHeader );
m_pHBorderWidget->setGeometry( widthRowHeader + 1, 0, m_pFrame->width() - widthRowHeader, heightColHeader );
m_pVBorderWidget->setGeometry( 0,heightColHeader + 1, widthRowHeader,
m_pFrame->height() - heightColHeader );
}
void KSpreadView::resizeEvent( QResizeEvent * )
{
refreshView();
}
void KSpreadView::popupChildMenu( KoChild* child, const QPoint& global_pos )
{
if ( !child )
return;
if ( m_popupChild != 0 )
delete m_popupChild;
m_popupChildObject = static_cast(child);
m_popupChild = new QPopupMenu( this );
m_popupChild->insertItem( i18n("Delete Embedded Document"), this, SLOT( slotPopupDeleteChild() ) );
m_popupChild->popup( global_pos );
}
void KSpreadView::slotPopupDeleteChild()
{
if ( !m_popupChildObject || !m_popupChildObject->table() )
return;
int ret = KMessageBox::warningYesNo(this,i18n("You are going to remove this embedded document.\nDo you want to continue?"),i18n("Delete Embedded Document"));
if ( ret == KMessageBox::Yes )
{
m_popupChildObject->table()->deleteChild( m_popupChildObject );
m_popupChildObject = 0;
}
}
void KSpreadView::popupColumnMenu(const QPoint & _point)
{
assert( m_pTable );
if ( !koDocument()->isReadWrite() )
return;
if (m_pPopupColumn != 0L )
delete m_pPopupColumn ;
m_pPopupColumn = new QPopupMenu( this );
m_cellLayout->plug( m_pPopupColumn );
m_pPopupColumn->insertSeparator();
m_cut->plug( m_pPopupColumn );
m_copy->plug( m_pPopupColumn );
m_paste->plug( m_pPopupColumn );
m_specialPaste->plug( m_pPopupColumn );
m_insertCellCopy->plug( m_pPopupColumn );
m_pPopupColumn->insertSeparator();
m_default->plug( m_pPopupColumn );
// If there is no selection
if((activeTable()->isRowSelected() == FALSE) && (activeTable()->isColumnSelected() == FALSE) )
{
m_areaName->plug( m_pPopupColumn );
}
m_resizeColumn->plug( m_pPopupColumn );
m_pPopupColumn->insertItem( i18n("Adjust Column"), this, SLOT(slotPopupAdjustColumn() ) );
m_pPopupColumn->insertSeparator();
m_insertColumn->plug( m_pPopupColumn );
m_deleteColumn->plug( m_pPopupColumn );
m_hideColumn->plug( m_pPopupColumn );
m_showSelColumns->setEnabled(false);
int i;
ColumnLayout * col;
QRect rect = activeTable()->selectionRect();
kdDebug(36001) << "Column: L: " << rect.left() << endl;
for ( i = rect.left(); i <= rect.right(); ++i )
{
if (i == 2) // "B"
{
col = activeTable()->columnLayout( 1 );
if ( col->isHide() )
{
m_showSelColumns->setEnabled(true);
m_showSelColumns->plug( m_pPopupColumn );
break;
}
}
col = activeTable()->columnLayout( i );
if ( col->isHide() )
{
m_showSelColumns->setEnabled(true);
m_showSelColumns->plug( m_pPopupColumn );
break;
}
}
QObject::connect( m_pPopupColumn, SIGNAL(activated( int ) ), this, SLOT(slotActivateTool( int ) ) );
m_pPopupColumn->popup( _point );
}
void KSpreadView::slotPopupAdjustColumn()
{
if ( !m_pTable )
return;
canvasWidget()->adjustArea();
}
void KSpreadView::popupRowMenu(const QPoint & _point )
{
assert( m_pTable );
if ( !koDocument()->isReadWrite() )
return;
if (m_pPopupRow != 0L )
delete m_pPopupRow ;
m_pPopupRow= new QPopupMenu();
m_cellLayout->plug( m_pPopupRow );
m_pPopupRow->insertSeparator();
m_cut->plug( m_pPopupRow );
m_copy->plug( m_pPopupRow );
m_paste->plug( m_pPopupRow );
m_specialPaste->plug( m_pPopupRow );
m_insertCellCopy->plug( m_pPopupRow );
m_pPopupRow->insertSeparator();
m_default->plug( m_pPopupRow );
// If there is no selection
if( (activeTable()->isRowSelected() == FALSE) && (activeTable()->isColumnSelected() == FALSE) )
{
m_areaName->plug( m_pPopupRow );
}
m_resizeRow->plug( m_pPopupRow );
m_pPopupRow->insertItem( i18n("Adjust Row"), this, SLOT( slotPopupAdjustRow() ) );
m_pPopupRow->insertSeparator();
m_insertRow->plug( m_pPopupRow );
m_deleteRow->plug( m_pPopupRow );
m_hideRow->plug( m_pPopupRow );
m_showSelColumns->setEnabled(false);
int i;
RowLayout * row;
QRect rect = activeTable()->selectionRect();
for ( i = rect.top(); i <= rect.bottom(); ++i )
{
kdDebug(36001) << "popupRow: " << rect.top() << endl;
if (i == 2)
{
row = activeTable()->rowLayout( 1 );
if ( row->isHide() )
{
m_showSelRows->setEnabled(true);
m_showSelRows->plug( m_pPopupRow );
break;
}
}
row = activeTable()->rowLayout( i );
if ( row->isHide() )
{
m_showSelRows->setEnabled(true);
m_showSelRows->plug( m_pPopupRow );
break;
}
}
QObject::connect( m_pPopupRow, SIGNAL( activated( int ) ), this, SLOT( slotActivateTool( int ) ) );
m_pPopupRow->popup( _point );
}
void KSpreadView::slotPopupAdjustRow()
{
if ( !m_pTable )
return;
canvasWidget()->adjustArea();
}
void KSpreadView::slotListChoosePopupMenu( )
{
assert( m_pTable );
if ( m_popupListChoose != 0L )
delete m_popupListChoose;
if(!koDocument()->isReadWrite() )
return;
m_popupListChoose = new QPopupMenu();
int id = 0;
QRect selection( m_pTable->selectionRect() );
if(selection.left()==0)
selection.setCoords(m_pCanvas->markerColumn(),m_pCanvas->markerRow(),
m_pCanvas->markerColumn(),m_pCanvas->markerRow());
KSpreadCell *cell = m_pTable->cellAt( m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
QString tmp=cell->text();
QStringList itemList;
KSpreadCell* c = m_pTable->firstCell();
for( ;c; c = c->nextCell() )
{
int col = c->column();
if ( selection.left() <= col && selection.right() >= col
&&!c->isObscuringForced()&& !(col==m_pCanvas->markerColumn()&& c->row()==m_pCanvas->markerRow()))
{
if(c->isString() && c->text()!=tmp && !c->text().isEmpty())
{
if(itemList.findIndex(c->text())==-1)
itemList.append(c->text());
}
}
}
for ( QStringList::Iterator it = itemList.begin(); it != itemList.end();++it )
m_popupListChoose->insertItem( (*it), id++ );
if(id==0)
return;
RowLayout *rl = m_pTable->rowLayout( m_pCanvas->markerRow());
int tx = m_pTable->columnPos( m_pCanvas->markerColumn(), m_pCanvas );
int ty = m_pTable->rowPos(m_pCanvas->markerRow(), m_pCanvas );
int h = rl->height( m_pCanvas );
if ( cell->extraYCells())
h = cell->extraHeight();
ty += h;
QPoint p( tx, ty );
QPoint p2 = m_pCanvas->mapToGlobal( p );
m_popupListChoose->popup( p2 );
QObject::connect( m_popupListChoose, SIGNAL( activated( int ) ),
this, SLOT( slotItemSelected( int ) ) );
}
void KSpreadView::slotItemSelected( int id)
{
QString tmp=m_popupListChoose->text(id);
KSpreadCell *cell = m_pTable->nonDefaultCell( m_pCanvas->markerColumn(),
m_pCanvas->markerRow() );
if(tmp==cell->text())
return;
if ( !m_pDoc->undoBuffer()->isLocked() )
{
KSpreadUndoSetText* undo = new KSpreadUndoSetText( m_pDoc, m_pTable, cell->text(), m_pCanvas->markerColumn(), m_pCanvas->markerRow(), cell->formatType());
m_pDoc->undoBuffer()->appendUndo( undo );
}
cell->setCellText( tmp, true );
editWidget()->setText( tmp );
}
void KSpreadView::openPopupMenu( const QPoint & _point )
{
assert( m_pTable );
if ( m_pPopupMenu != 0L )
delete m_pPopupMenu;
if(!koDocument()->isReadWrite() )
return;
m_pPopupMenu = new QPopupMenu();
m_cellLayout->plug( m_pPopupMenu );
m_pPopupMenu->insertSeparator();
m_cut->plug( m_pPopupMenu );
m_copy->plug( m_pPopupMenu );
m_paste->plug( m_pPopupMenu );
m_specialPaste->plug( m_pPopupMenu );
m_insertCellCopy->plug( m_pPopupMenu );
m_pPopupMenu->insertSeparator();
m_delete->plug( m_pPopupMenu );
m_adjust->plug( m_pPopupMenu );
m_default->plug( m_pPopupMenu );
// If there is no selection
if( (activeTable()->isRowSelected() == FALSE) && (activeTable()->isColumnSelected() == FALSE) )
{
m_areaName->plug( m_pPopupMenu );
m_pPopupMenu->insertSeparator();
m_insertCell->plug( m_pPopupMenu );
m_removeCell->plug( m_pPopupMenu );
}
KSpreadCell *cell = m_pTable->cellAt( m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
m_pPopupMenu->insertSeparator();
m_addModifyComment->plug( m_pPopupMenu );
if( !cell->comment(m_pCanvas->markerColumn(), m_pCanvas->markerRow()).isEmpty() )
{
m_removeComment->plug( m_pPopupMenu );
}
if(activeTable()->testListChoose(QPoint(m_pCanvas->markerColumn(), m_pCanvas->markerRow())))
{
m_pPopupMenu->insertSeparator();
m_pPopupMenu->insertItem( i18n("Selection List..."), this, SLOT( slotListChoosePopupMenu() ) );
}
// Remove informations about the last tools we offered
m_lstTools.clear();
m_lstTools.setAutoDelete( true );
if(!activeTable()->getWordSpelling( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() )).isEmpty())
{
m_popupMenuFirstToolId = 10;
int i = 0;
QValueList tools = KDataToolInfo::query( "QString", "text/plain", m_pDoc->instance() );
if( tools.count() > 0 )
{
m_pPopupMenu->insertSeparator();
QValueList::Iterator entry = tools.begin();
for( ; entry != tools.end(); ++entry )
{
QStringList lst = (*entry).userCommands();
QStringList::ConstIterator it = lst.begin();
// ### Torben: Insert pixmaps here, too
for (; it != lst.end(); ++it )
m_pPopupMenu->insertItem( *it, m_popupMenuFirstToolId + i++ );
lst = (*entry).commands();
it = lst.begin();
for (; it != lst.end(); ++it )
{
ToolEntry *t = new ToolEntry;
t->command = *it;
t->info = *entry;
m_lstTools.append( t );
}
}
QObject::connect( m_pPopupMenu, SIGNAL( activated( int ) ), this, SLOT( slotActivateTool( int ) ) );
}
}
m_pPopupMenu->popup( _point );
}
void KSpreadView::slotActivateTool( int _id )
{
Q_ASSERT( m_pTable );
// Is it the id of a tool in the latest popupmenu ?
if( _id < m_popupMenuFirstToolId )
return;
ToolEntry* entry = m_lstTools.at( _id - m_popupMenuFirstToolId );
KDataTool* tool = entry->info.createTool();
if ( !tool )
{
kdDebug(36001) << "Could not create Tool" << endl;
return;
}
QString text = activeTable()->getWordSpelling( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ));
if ( tool->run( entry->command, &text, "QString", "text/plain") )
{
activeTable()->setWordSpelling( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ),text);
KSpreadCell *cell = m_pTable->cellAt( m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
editWidget()->setText( cell->text() );
}
}
void KSpreadView::deleteSelection()
{
Q_ASSERT( m_pTable );
m_pTable->deleteSelection( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
resultOfCalc();
updateEditWidget();
}
void KSpreadView::adjust()
{
if( (activeTable()->isRowSelected()) || (activeTable()->isColumnSelected()) )
{
KMessageBox::error( this, i18n("Area too large!"));
}
else
{
canvasWidget()->adjustArea();
}
}
void KSpreadView::clearTextSelection()
{
Q_ASSERT( m_pTable );
m_pTable->clearTextSelection( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
updateEditWidget();
}
void KSpreadView::clearCommentSelection()
{
Q_ASSERT( m_pTable );
m_pTable->setSelectionRemoveComment( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
updateEditWidget();
}
void KSpreadView::clearValiditySelection()
{
Q_ASSERT( m_pTable );
m_pTable->clearValiditySelection( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
updateEditWidget();
}
void KSpreadView::clearConditionalSelection()
{
Q_ASSERT( m_pTable );
m_pTable->clearConditionalSelection( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
updateEditWidget();
}
void KSpreadView::defaultSelection()
{
Q_ASSERT( m_pTable );
m_pTable->defaultSelection( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) );
updateEditWidget();
}
void KSpreadView::slotInsert()
{
QRect r( activeTable()-> selectionRect() );
if(r.left()==0)
r.setCoords(m_pCanvas->markerColumn(), m_pCanvas->markerRow()
,m_pCanvas->markerColumn(), m_pCanvas->markerRow());
KSpreadinsert dlg( this, "Insert", r,KSpreadinsert::Insert );
dlg.exec();
}
void KSpreadView::slotRemove()
{
QRect r( activeTable()-> selectionRect() );
if(r.left()==0)
r.setCoords(m_pCanvas->markerColumn(), m_pCanvas->markerRow()
,m_pCanvas->markerColumn(), m_pCanvas->markerRow());
KSpreadinsert dlg( this, "Remove", r,KSpreadinsert::Remove );
dlg.exec();
}
void KSpreadView::slotInsertCellCopy()
{
if ( !m_pTable )
return;
QRect r( activeTable()->selectionRect() );
if(r.left()==0 )
r.setCoords(m_pCanvas->markerColumn(), m_pCanvas->markerRow() ,
m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
if( !m_pTable->testAreaPasteInsert())
m_pTable->paste( QPoint( r.left(), r.top() ) ,true, Normal,OverWrite,true);
else
{
QRect r( activeTable()-> selectionRect() );
KSpreadpasteinsert dlg( this, "Remove", r );
dlg.exec();
}
if(m_pTable->getAutoCalc())
m_pTable->recalc();
updateEditWidget();
}
void KSpreadView::setAreaName()
{
KSpreadarea dlg( this, "Area Name",QPoint(m_pCanvas->markerColumn(), m_pCanvas->markerRow()) );
dlg.exec();
}
void KSpreadView::showAreaName()
{
KSpreadreference dlg( this, "Show Area" );
dlg.exec();
}
void KSpreadView::resizeRow()
{
if( activeTable()->isColumnSelected() )
KMessageBox::error( this, i18n("Area too large!"));
else
{
KSpreadresize2 dlg( this, "Resize Row", KSpreadresize2::resize_row );
dlg.exec();
}
}
void KSpreadView::resizeColumn()
{
if( activeTable()->isRowSelected() )
KMessageBox::error( this, i18n("Area too large!"));
else
{
KSpreadresize2 dlg( this, "Resize Column", KSpreadresize2::resize_column );
dlg.exec();
}
}
void KSpreadView::equalizeRow()
{
if( activeTable()->isColumnSelected() )
KMessageBox::error( this, i18n("Area too large!"));
else
canvasWidget()->equalizeRow();
}
void KSpreadView::equalizeColumn()
{
if( activeTable()->isRowSelected() )
KMessageBox::error( this, i18n("Area too large!"));
else
canvasWidget()->equalizeColumn();
}
void KSpreadView::layoutDlg()
{
QRect selection( m_pTable->selectionRect() );
if ( selection.contains( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) ) )
CellLayoutDlg dlg( this, m_pTable, selection.left(), selection.top(),
selection.right(), selection.bottom() );
else
CellLayoutDlg dlg( this, m_pTable, m_pCanvas->markerColumn(), m_pCanvas->markerRow(), m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
}
void KSpreadView::paperLayoutDlg()
{
m_pDoc->paperLayoutDlg();
}
void KSpreadView::multiRow( bool b )
{
if ( m_toolbarLock )
return;
if ( m_pTable != 0L )
m_pTable->setSelectionMultiRow( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), b );
}
void KSpreadView::alignLeft( bool b )
{
if ( m_toolbarLock )
return;
if ( m_pTable != 0L )
{
if ( !b )
m_pTable->setSelectionAlign( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), KSpreadLayout::Undefined );
else
m_pTable->setSelectionAlign( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), KSpreadLayout::Left );
}
}
void KSpreadView::alignRight( bool b )
{
if ( m_toolbarLock )
return;
if ( m_pTable != 0L )
{
if ( !b )
m_pTable->setSelectionAlign( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), KSpreadLayout::Undefined );
else
m_pTable->setSelectionAlign( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), KSpreadLayout::Right );
}
}
void KSpreadView::alignCenter( bool b )
{
if ( m_toolbarLock )
return;
if ( m_pTable != 0L )
{
if ( !b )
m_pTable->setSelectionAlign( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), KSpreadLayout::Undefined );
else
m_pTable->setSelectionAlign( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), KSpreadLayout::Center );
}
}
void KSpreadView::alignTop( bool b )
{
if ( m_toolbarLock )
return;
if ( !b )
return;
if ( m_pTable != 0L )
m_pTable->setSelectionAlignY( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), KSpreadLayout::Top );
}
void KSpreadView::alignBottom( bool b )
{
if ( m_toolbarLock )
return;
if ( !b )
return;
if ( m_pTable != 0L )
m_pTable->setSelectionAlignY( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), KSpreadLayout::Bottom );
}
void KSpreadView::alignMiddle( bool b )
{
if ( m_toolbarLock )
return;
if ( !b )
return;
if ( m_pTable != 0L )
m_pTable->setSelectionAlignY( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), KSpreadLayout::Middle );
}
void KSpreadView::moneyFormat(bool b)
{
if ( m_toolbarLock )
return;
if ( m_pTable != 0L )
m_pTable->setSelectionMoneyFormat( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ),b );
updateEditWidget();
}
void KSpreadView::precisionPlus()
{
if ( m_pTable != 0L )
m_pTable->setSelectionPrecision( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), 1 );
}
void KSpreadView::precisionMinus()
{
if ( m_pTable != 0L )
m_pTable->setSelectionPrecision( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ), -1 );
}
void KSpreadView::percent( bool b)
{
if ( m_toolbarLock )
return;
if ( m_pTable != 0L )
m_pTable->setSelectionPercent( QPoint( m_pCanvas->markerColumn(), m_pCanvas->markerRow() ) ,b );
updateEditWidget();
}
void KSpreadView::insertObject()
{
KoDocumentEntry e = m_insertPart->documentEntry();//KoPartSelectDia::selectPart( m_pCanvas );
if ( e.isEmpty() )
return;
(void)new KSpreadInsertHandler( this, m_pCanvas, e );
}
void KSpreadView::insertChart()
{
if( activeTable()->isColumnSelected() || activeTable()->isRowSelected() )
{
KMessageBox::error( this, i18n("Area too large!"));
return;
}
QValueList vec = KoDocumentEntry::query( "'KOfficeChart' in ServiceTypes" );
if ( vec.isEmpty() )
{
KMessageBox::error( this, i18n("No charting component registered") );
return;
}
(void)new KSpreadInsertHandler( this, m_pCanvas, vec[0], TRUE );
}
/*
// TODO Use KoView setScaling/xScaling/yScaling instead
void KSpreadView::zoomMinus()
{
if ( m_fZoom <= 0.25 )
return;
m_fZoom -= 0.25;
if ( m_pTable != 0L )
m_pTable->setLayoutDirtyFlag();
m_pCanvas->repaint();
m_pVBorderWidget->repaint();
m_pHBorderWidget->repaint();
}
void KSpreadView::zoomPlus()
{
if ( m_fZoom >= 3 )
return;
m_fZoom += 0.25;
if ( m_pTable != 0L )
m_pTable->setLayoutDirtyFlag();
m_pCanvas->repaint();
m_pVBorderWidget->repaint();
m_pHBorderWidget->repaint();
}
*/
void KSpreadView::removeTable()
{
if ( doc()->map()->count() <= 1||(m_pTabBar->listshow().count()<=1) )
{
KNotifyClient::beep();
KMessageBox::sorry( this, i18n("You cannot delete the only table of the map."), i18n("Remove Table") ); // FIXME bad english? no english!
return;
}
KNotifyClient::beep();
int ret = KMessageBox::warningYesNo(this,i18n("You are going to remove the active table.\nDo you want to continue?"),i18n("Remove Table"));
if ( ret == KMessageBox::Yes )
{
if ( m_pCanvas->editor() )
{
m_pCanvas->deleteEditor( false );
}
m_pDoc->setModified( true );
KSpreadTable *tbl = activeTable();
tbl->removeTable();
doc()->map()->removeTable( tbl );
delete tbl;
}
}
void KSpreadView::slotRename()
{
m_pTabBar->slotRename();
}
void KSpreadView::setText( const QString& _text )
{
if ( m_pTable == 0L )
return;
m_pTable->setText( m_pCanvas->markerRow(), m_pCanvas->markerColumn(), _text );
KSpreadCell* cell = m_pTable->cellAt( m_pCanvas->markerColumn(), m_pCanvas->markerRow() );
if(cell->isString() && !_text.isEmpty() && !_text.at(0).isDigit())
m_pDoc->addStringCompletion(_text);
}
//------------------------------------------------
//
// Document signals
//
//------------------------------------------------
void KSpreadView::slotAddTable( KSpreadTable *_table )
{
addTable( _table );
}
void KSpreadView::slotUpdateView( KSpreadTable *_table )
{
// kdDebug(36001)<<"void KSpreadView::slotUdateView( KSpreadTable *_table )\n";
// Do we display this table ?
if ( _table != m_pTable )
return;
m_pCanvas->update();
}
void KSpreadView::slotUpdateView( KSpreadTable *_table, const QRect& _rect )
{
// qDebug("void KSpreadView::slotUpdateView( KSpreadTable *_table, const QRect& %i %i|%i %i )\n",_rect.left(),_rect.top(),_rect.right(),_rect.bottom());
// Do we display this table ?
if ( _table != m_pTable )
return;
m_pCanvas->updateCellRect( _rect );
}
void KSpreadView::slotUpdateHBorder( KSpreadTable *_table )
{
// kdDebug(36001)<<"void KSpreadView::slotUpdateHBorder( KSpreadTable *_table )\n";
// Do we display this table ?
if ( _table != m_pTable )
return;
m_pHBorderWidget->update();
}
void KSpreadView::slotUpdateVBorder( KSpreadTable *_table )
{
// kdDebug("void KSpreadView::slotUpdateVBorder( KSpreadTable *_table )\n";
// Do we display this table ?
if ( _table != m_pTable )
return;
m_pVBorderWidget->update();
}
void KSpreadView::slotChangeChooseSelection( KSpreadTable *_table, const QRect &_old, const QRect &_new )
{
// Do we display this table ?
if ( _table != m_pTable )
return;
m_pCanvas->updateChooseMarker( _old, _new );
// Emit a signal for internal use
emit sig_chooseSelectionChanged( _table, _new );
}
void KSpreadView::slotChangeSelection( KSpreadTable *_table, const QRect &_old, const QRect& _old_marker )
{
QRect n = _table->selectionRect();
// QRect m = _table->marker();
// printf ("void KSpreadView::slotChangeSelection( KSpreadTable *_table, const QRect &_old %i %i|%i %i, const QPoint &m %i %i )\n",_old.left(),_old.top(),_old.right(),_old.bottom(),_old_marker.x(),_old_marker.y() );
// printf (" const QRect &_new %i %i|%i %i, const QPoint &m %i %i )\n",n.left(),n.top(),n.right(),n.bottom(),m.x(),m.y() );
// Emit a signal for internal use
emit sig_selectionChanged( _table, n );
// Empty selection ?
// Activate or deactivate some actions. This code is duplicated
// in KSpreadView::slotUnselect
if ( ( n.left() == 0 && n.top() == 0 )
|| _table->isRowSelected() || _table->isColumnSelected() )
{
m_tableFormat->setEnabled( FALSE );
m_mergeCell->setEnabled(false);
m_insertChartFrame->setEnabled(false);
}
else if ( (n.left() != n.right()) || (n.top() != n.bottom()) )
{
m_tableFormat->setEnabled( TRUE );
m_mergeCell->setEnabled(true);
m_insertChartFrame->setEnabled(true);
}
if( _table->isColumnSelected() )
{
m_resizeRow->setEnabled(false);
m_equalizeRow->setEnabled(false);
}
else
{
m_resizeRow->setEnabled(true);
m_equalizeRow->setEnabled(true);
}
if( _table->isRowSelected() )
{
m_resizeColumn->setEnabled(false);
m_equalizeColumn->setEnabled(false);
}
else
{
m_resizeColumn->setEnabled(true);
m_equalizeColumn->setEnabled(true);
}
resultOfCalc();
// Send some event around. This is read for example
// by the calculator plugin.
KSpreadSelectionChanged ev( n, activeTable()->name() );
QApplication::sendEvent( this, &ev );
// Do we display this table ?
if ( _table != m_pTable )
return;
m_pCanvas->updateSelection( _old, _old_marker );
m_pVBorderWidget->update();
m_pHBorderWidget->update();
}
void KSpreadView::resultOfCalc()
{
double result=0.0;
int nbCell=0;
QRect n = activeTable()->selectionRect();
QRect tmpRect(n);
if(n.left()==0)
tmpRect.setCoords( m_pCanvas->markerColumn(), m_pCanvas->markerRow(),
m_pCanvas->markerColumn(), m_pCanvas->markerRow());
MethodOfCalc tmpMethod=m_pDoc->getTypeOfCalc() ;
if ( tmpMethod != NoneCalc )
{
if( activeTable()->isColumnSelected() )
{
KSpreadCell* c = activeTable()->firstCell();
for( ;c; c = c->nextCell() )
{
int col = c->column();
if ( tmpRect.left() <= col && tmpRect.right() >= col
&&!c->isObscuringForced())
{
if(c->isNumeric())
{
double val=c->valueDouble();
switch(tmpMethod)
{
case SumOfNumber:
result+=val;
break;
case Average:
result+=val;
break;
case Min:
if(result!=0)
result=QMIN(val,result);
else
result=val;
break;
case Max:
if(result!=0)
result=QMAX(val,result);
else
result=val;
break;
case Count:
case NoneCalc:
break;
default:
break;
}
nbCell++;
}
}
}
}
else if( activeTable()->isRowSelected() )
{
KSpreadCell* c = activeTable()->firstCell();
for( ; c; c = c->nextCell() )
{
int row = c->row();
if ( tmpRect.top() <= row && tmpRect.bottom() >= row
&&!c->isObscuringForced())
{
if(c->isNumeric())
{
double val=c->valueDouble();
switch(tmpMethod )
{
case SumOfNumber:
result+=val;
break;
case Average:
result+=val;
break;
case Min:
if(result!=0)
result=QMIN(val,result);
else
result=val;
break;
case Max:
if(result!=0)
result=QMAX(val,result);
else
result=val;
break;
case Count:
case NoneCalc:
break;
default:
break;
}
nbCell++;
}
}
}
}
else
{
for (int i=tmpRect.left();i<=tmpRect.right();i++)
for(int j=tmpRect.top();j<=tmpRect.bottom();j++)
{
KSpreadCell *cell = activeTable()->cellAt( i, j );
if(!cell->isDefault() && cell->isNumeric())
{
double val= cell->valueDouble();
switch(tmpMethod )
{
case SumOfNumber:
result+=val;
break;
case Average:
result+=val;
break;
case Min:
if(result!=0)
result=QMIN(val,result);
else
result=val;
break;
case Max:
if(result!=0)
result=QMAX(val,result);
else
result=val;
break;
case Count:
case NoneCalc:
break;
default:
break;
}
nbCell++;
}
}
}
}
QString tmp;
switch(tmpMethod )
{
case SumOfNumber:
tmp=i18n(" Sum: %1").arg(result);
break;
case Average:
result=result/nbCell;
tmp=i18n("Average: %1").arg(result);
break;
case Min:
tmp=i18n("Min: %1").arg(result);
break;
case Max:
tmp=i18n("Max: %1").arg(result);
break;
case Count:
tmp=i18n("Count: %1").arg(nbCell);
break;
case NoneCalc:
tmp="";
break;
}
if ( m_sbCalcLabel )
m_sbCalcLabel->setText(QString(" ")+tmp+' ');
}
void KSpreadView::statusBarClicked(int _id)
{
if(!koDocument()->isReadWrite() )
return;
if(_id==0) //menu calc
{
QPoint mousepos =QCursor::pos();
((QPopupMenu*)factory()->container("calc_popup",this))->popup(mousepos);
}
}
void KSpreadView::menuCalc(bool)
{
if( m_menuCalcMin->isChecked())
{
doc()->setTypeOfCalc(Min);
}
else if(m_menuCalcMax->isChecked())
{
doc()->setTypeOfCalc(Max);
}
else if(m_menuCalcCount->isChecked())
{
doc()->setTypeOfCalc(Count);
}
else if(m_menuCalcAverage->isChecked())
{
doc()->setTypeOfCalc(Average);
}
else if(m_menuCalcSum->isChecked())
{
doc()->setTypeOfCalc(SumOfNumber);
}
else if( m_menuCalcNone->isChecked())
doc()->setTypeOfCalc(NoneCalc);
resultOfCalc();
}
void KSpreadView::slotUnselect( KSpreadTable *_table, const QRect& _old )
{
// Do we display this table ?
if ( _table != m_pTable )
return;
// Unselect the action which only works on a selection
// with mutiple cells.
m_tableFormat->setEnabled( FALSE );
m_mergeCell->setEnabled(false);
m_insertChartFrame->setEnabled(false);
m_pCanvas->updateSelection( _old, _table->marker() );
m_pVBorderWidget->update();
m_pHBorderWidget->update();
}
void KSpreadView::repaintPolygon( const QPointArray& polygon )
{
QPointArray arr = polygon;
QWMatrix m = matrix()/*.invert()*/;
for( int i = 0; i < 4; ++i )
arr.setPoint( i, m.map( arr.point( i ) ) );
emit regionInvalidated( QRegion( arr ), TRUE );
}
void KSpreadView::paintContent( QPainter& painter, const QRect& rect, bool transparent )
{
m_pDoc->paintContent( painter, rect, transparent, activeTable() );
}
QWMatrix KSpreadView::matrix() const
{
QWMatrix m;
m.translate( -m_pCanvas->xOffset(), -m_pCanvas->yOffset() );
m.scale( zoom(), zoom() );
return m;
}
void KSpreadView::transformPart()
{
Q_ASSERT( selectedChild() );
if ( m_transformToolBox.isNull() )
{
m_transformToolBox = new KoTransformToolBox( selectedChild(), topLevelWidget() );
m_transformToolBox->show();
m_transformToolBox->setDocumentChild( selectedChild() );
}
else
{
m_transformToolBox->show();
m_transformToolBox->raise();
}
}
void KSpreadView::slotChildSelected( KoDocumentChild* ch )
{
m_transform->setEnabled( TRUE );
if ( !m_transformToolBox.isNull() )
{
m_transformToolBox->setEnabled( TRUE );
m_transformToolBox->setDocumentChild( ch );
}
}
void KSpreadView::slotChildUnselected( KoDocumentChild* )
{
m_transform->setEnabled( FALSE );
if ( !m_transformToolBox.isNull() )
{
m_transformToolBox->setEnabled( FALSE );
}
}
void KSpreadView::deleteEditor( bool saveChanges )
{
m_pCanvas->deleteEditor( saveChanges );
}
DCOPObject* KSpreadView::dcopObject()
{
if ( !m_dcop )
m_dcop = new KSpreadViewIface( this );
return m_dcop;
}
QWidget *KSpreadView::canvas()
{
return canvasWidget();
}
int KSpreadView::canvasXOffset() const
{
return canvasWidget()->xOffset();
}
int KSpreadView::canvasYOffset() const
{
return canvasWidget()->yOffset();
}
void KSpreadView::guiActivateEvent( KParts::GUIActivateEvent *ev )
{
if ( ev->activated() )
{
if ( m_sbCalcLabel )
{
resultOfCalc();
}
}
else
{
/*if(m_sbCalcLabel)
{
disconnect(m_sbCalcLabel,SIGNAL(pressed( int )),this,SLOT(statusBarClicked(int)));
}*/
}
KoView::guiActivateEvent( ev );
}
void KSpreadView::openPopupMenuMenuPage( const QPoint & _point )
{
if(!koDocument()->isReadWrite() )
return;
if( m_pTabBar )
{
m_removeTable->setEnabled( m_pTabBar->listshow().count()>1);
static_cast(factory()->container("menupage_popup",this))->popup(_point);
}
}
void KSpreadView::updateBorderButton()
{
m_showPageBorders->setChecked( m_pTable->isShowPageBorders() );
}
#include "kspread_view.moc"
diff --git a/kspread/kspread_view.h b/kspread/kspread_view.h
index f462cf1e5a..fba01d420a 100644
--- a/kspread/kspread_view.h
+++ b/kspread/kspread_view.h
@@ -1,694 +1,700 @@
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __kspread_gui_h__
#define __kspread_gui_h__
class QFrame;
class QScrollBar;
class QButton;
class KSpreadView;
class KSpreadEditWidget;
class KSpreadCanvas;
class KSpreadHBorder;
class KSpreadVBorder;
class KSpreadScripts;
class KSpreadTable;
class KSpreadDoc;
class KSpreadPaperLayout;
class KSpreadChildPicture;
class KSpreadChildFrame;
class KSpreadShell;
class KSpreadTabBar;
class KSpreadEditWidget;
class KSpreadCanvas;
class KSpreadHBorder;
class KSpreadVBorder;
class KSpreadChild;
class KSpreadCell;
class KSpreadLocationEditWidget;
class KoDocumentEntry;
class KStatusBarLabel;
class TKSelectColorAction;
class KAction;
class KSelectAction;
class KFontAction;
class KFontSizeAction;
class KToggleAction;
class KoPartSelectAction;
class KSpreadSpell;
//class KMacroCommand;
class KActionMenu;
class DCOPObject;
#include
#include
#include
#include
#include
#include
#include
#include
#include
/**
*/
class KSpreadView : public KoView
{
friend class KSpreadCanvas;
Q_OBJECT
public:
KSpreadView( QWidget *_parent, const char *_name, KSpreadDoc *_doc );
~KSpreadView();
KSpreadCanvas* canvasWidget() const { return m_pCanvas; }
KSpreadHBorder* hBorderWidget() { return m_pHBorderWidget; }
KSpreadVBorder* vBorderWidget() { return m_pVBorderWidget; }
QScrollBar* horzScrollBar() { return m_pHorzScrollBar; }
QScrollBar* vertScrollBar() { return m_pVertScrollBar; }
KSpreadEditWidget* editWidget() { return m_pEditWidget; }
//QLabel* posWidget() { return m_pPosWidget; }
KSpreadLocationEditWidget* posWidget() { return m_pPosWidget; }
KSpreadDoc* doc() { return m_pDoc; }
void addTable( KSpreadTable *_t );
//void removeTable( KSpreadTable *_t );
void removeAllTables();
void setActiveTable( KSpreadTable *_t,bool updateTable=true );
const KSpreadTable* activeTable() const { return m_pTable; }
KSpreadTable* activeTable() { return m_pTable; }
KSpreadTabBar* tabBar() { return m_pTabBar;}
void openPopupMenu( const QPoint &_global );
void popupRowMenu(const QPoint & _point ) ;
void popupColumnMenu( const QPoint & _point);
// void showFormulaToolBar( bool show );
/**
* Used by @ref KSpreadEditWidget. Sets the text of the active cell.
*/
void setText( const QString& _text );
void enableUndo( bool _b );
void enableRedo( bool _b );
/**
* Called by @ref KSpreadInsertHandler
*
* @param _geometry is the zoomed geometry of the new child.
*/
void insertChart( const QRect& _geometry, KoDocumentEntry& _entry );
/**
* Called by @ref KSpreadInsertHandler
*
* @param _geometry is the geometry of the new child.
*/
void insertChild( const QRect& _geometry, KoDocumentEntry& _entry );
virtual void print( KPrinter &printer );
virtual void setupPrinter( KPrinter &printer );
void paintContent( QPainter& painter, const QRect& rect, bool transparent );
/**
* Fills the @ref KSpreadEditWidget with the current cells
* content. This function is usually called after the
* cursor moved.
*/
void updateEditWidget();
/**
* Same as updateEditEidget() but no update of menus and toolbars
*/
void updateEditWidgetOnPress();
/**
* Called before saving, to finish the current edition (if any)
*/
void deleteEditor( bool saveChanges = true );
virtual DCOPObject* dcopObject();
virtual QWidget *canvas();
virtual int canvasXOffset() const;
virtual int canvasYOffset() const;
/**
* @reimp
*/
KoDocument *hitTest( const QPoint &pos );
void initConfig();
/**
* refresh view when you hide/show vertical scrollbar
*/
void refreshView();
bool isLoading() {return m_bLoading;}
/**
* write in statusBar result of calc (Min, or Max, average, sum, count)
*/
void resultOfCalc();
void initCalcMenu();
void changeNbOfRecentFiles(int _nb);
void openPopupMenuMenuPage( const QPoint & _point );
void updateBorderButton();
public slots:
void initialPosition();
/**
* Actions
*/
void transformPart();
void copySelection();
void cutSelection();
void deleteSelection();
void clearTextSelection();
void clearCommentSelection();
void clearValiditySelection();
void clearConditionalSelection();
void RecalcWorkBook();
void RecalcWorkSheet();
void paste();
void specialPaste();
void editCell();
void setAreaName();
void showAreaName();
void undo();
void redo();
void adjust();
void defaultSelection();
void paperLayoutDlg();
void insertObject();
+ void insertFromDatabase();
+ void insertFromTextfile();
+ void insertFromClipboard();
void editGlobalScripts();
void editLocalScripts();
void reloadScripts();
void runLocalScript();
void togglePageBorders( bool );
void find();
void replace();
void conditional();
void validity();
void insertSeries();
void sort();
void insertHyperlink();
void consolidate();
void insertTable();
void removeTable();
void hideTable();
void showTable();
void helpUsing();
void insertChart();
void moneyFormat(bool b);
void alignLeft( bool b );
void alignRight( bool b );
void alignCenter( bool b );
void alignTop( bool b );
void alignMiddle( bool b );
void alignBottom( bool b );
void multiRow( bool b );
void precisionMinus();
void precisionPlus();
void percent(bool b);
void fontSelected( const QString &_font );
void fontSizeSelected( int size );
void bold( bool b );
void italic( bool b );
void underline( bool b );
void strikeOut( bool b );
void deleteColumn();
void insertColumn();
void deleteRow();
void insertRow();
void hideRow();
void showRow();
void showSelRows();
void hideColumn();
void showColumn();
void showSelColumns();
void insertMathExpr();
void formulaSelection( const QString &_math );
void changeTextColor();
void changeBackgroundColor();
void sortInc();
void sortDec();
void layoutDlg();
void borderBottom();
void borderRight();
void borderLeft();
void borderTop();
void borderOutline();
void borderAll();
void borderRemove();
void changeBorderColor();
void tableFormat();
// void oszilloscope();
void autoSum();
void resizeRow();
void resizeColumn();
void increaseFontSize();
void decreaseFontSize();
void upper();
void lower();
void equalizeColumn();
void equalizeRow();
void preference();
void firstLetterUpper();
void verticalText(bool );
void addModifyComment();
void removeComment();
void changeAngle();
void mergeCell();
void dissociateCell();
void gotoCell();
void increaseIndent();
void decreaseIndent();
void copyAsText();
/**
* @ref #tabBar is connected to this slot.
* When the user selects a new table using the @ref #tabBar this slot
* is signaled.
*/
void changeTable( const QString& _name );
void nextTable();
void previousTable();
void firstTable();
void lastTable();
void sortList();
void statusBarClicked(int _id);
void menuCalc(bool);
protected slots:
/**
* Popup menu
*/
void slotActivateTool( int _id );
void slotInsert();
void slotInsertCellCopy();
void slotRemove();
void slotRename();
/**
* Invoked if the popup menu for an embedded document should be opened.
*/
void popupChildMenu( KoChild*, const QPoint& global_pos );
void slotPopupDeleteChild();
/**
* Border popup menu
*/
void slotPopupAdjustColumn();
void slotPopupAdjustRow();
/**
* Scroll @ref #tabBar.
*/
void slotScrollToFirstTable();
/**
* Scroll @ref #tabBar.
*/
void slotScrollToLeftTable();
/**
* Scroll @ref #tabBar.
*/
void slotScrollToRightTable();
/**
* Scroll @ref #tabBar.
*/
void slotScrollToLastTable();
/**
* list from list choose
*/
void slotItemSelected( int );
void slotListChoosePopupMenu( );
protected slots:
void repaintPolygon( const QPointArray& );
void slotChildSelected( KoDocumentChild* ch );
void slotChildUnselected( KoDocumentChild* );
public slots:
// Document signals
void slotUnselect( KSpreadTable *_table, const QRect& _old );
void slotUpdateView( KSpreadTable *_table );
void slotUpdateView( KSpreadTable *_table, const QRect& );
void slotUpdateHBorder( KSpreadTable *_table );
void slotUpdateVBorder( KSpreadTable *_table );
void slotChangeSelection( KSpreadTable *_table, const QRect &_old, const QRect &_old_marker );
void slotChangeChooseSelection( KSpreadTable *_table, const QRect &_old, const QRect &_new );
void slotAddTable( KSpreadTable *_table );
void slotRemoveChild( KSpreadChild *_child );
void slotUpdateChildGeometry( KSpreadChild *_child );
void slotTableRenamed( KSpreadTable* table, const QString& old_name );
void slotTableHidden( KSpreadTable*_table );
void slotTableShown( KSpreadTable*_table );
void slotTableRemoved( KSpreadTable*_table );
void slotTableActivated( KSpreadTable* table );
void slotRefreshView( );
void slotRefreshLocale();
void extraSpelling();
void spellCheckerReady();
void spellCheckerMisspelling( const QString &, const QStringList &, unsigned int);
void spellCheckerCorrected( const QString &, const QString &, unsigned int);
void spellCheckerDone( const QString & );
void spellCheckerFinished( );
void startKSpell();
virtual int leftBorder() const;
virtual int rightBorder() const;
virtual int topBorder() const;
virtual int bottomBorder() const;
signals:
void sig_selectionChanged( KSpreadTable* _table, const QRect& _selection );
void sig_chooseSelectionChanged( KSpreadTable* _table, const QRect& _selection );
protected:
// bool eventKeyPressed( QKeyEvent* _event, bool choose );
virtual void keyPressEvent ( QKeyEvent * _ev );
virtual void resizeEvent( QResizeEvent *_ev );
virtual QWMatrix matrix() const;
/**
* Activates the formula editor for the current cell.
* This function is usually called if the user presses
* a button in the formula toolbar.
*/
void activateFormulaEditor();
virtual void updateReadWrite( bool readwrite );
virtual void guiActivateEvent( KParts::GUIActivateEvent *ev );
private:
// GUI stuff
QButton* newIconButton( const char *_file, bool _kbutton = false, QWidget *_parent = 0L );
QScrollBar *m_pHorzScrollBar;
QScrollBar *m_pVertScrollBar;
KSpreadCanvas *m_pCanvas;
KSpreadVBorder *m_pVBorderWidget;
KSpreadHBorder *m_pHBorderWidget;
KSpreadEditWidget *m_pEditWidget;
QWidget *m_pFrame;
QFrame *m_pToolWidget;
QButton *m_pTabBarFirst;
QButton *m_pTabBarLeft;
QButton *m_pTabBarRight;
QButton *m_pTabBarLast;
QButton *m_pOkButton;
QButton *m_pCancelButton;
KSpreadTabBar *m_pTabBar;
//QLabel *m_pPosWidget;
KSpreadLocationEditWidget *m_pPosWidget;
KToggleAction* m_bold;
KToggleAction* m_italic;
KToggleAction* m_underline;
KToggleAction* m_strikeOut;
KToggleAction* m_percent;
KAction* m_precplus;
KAction* m_precminus;
KToggleAction* m_money;
KToggleAction* m_alignLeft;
KToggleAction* m_alignCenter;
KToggleAction* m_alignRight;
KToggleAction* m_alignTop;
KToggleAction* m_alignMiddle;
KToggleAction* m_alignBottom;
KAction* m_transform;
KAction* m_copy;
KAction* m_paste;
KAction* m_cut;
KAction* m_specialPaste;
KAction* m_delete;
KAction* m_clearText;
KAction* m_clearComment;
KAction* m_clearValidity;
KAction* m_clearConditional;
KAction* m_recalc_workbook;
KAction* m_recalc_worksheet;
KAction* m_adjust;
KAction* m_editCell;
KAction* m_undo;
KAction* m_redo;
KAction* m_paperLayout;
+ KAction* m_insertFromDatabase;
+ KAction* m_insertFromTextfile;
+ KAction* m_insertFromClipboard;
KAction* m_insertTable;
KAction* m_removeTable;
KAction* m_renameTable;
KAction* m_nextTable;
KAction* m_prevTable;
KAction* m_firstTable;
KAction* m_lastTable;
KAction* m_editGlobalScripts;
KAction* m_editLocalScripts;
KAction* m_reloadScripts;
KAction* m_conditional;
KAction* m_validity;
KAction* m_sort;
KAction* m_consolidate;
KAction* m_help;
KAction* m_insertCellCopy;
KToggleAction* m_multiRow;
KFontAction* m_selectFont;
KFontSizeAction* m_selectFontSize;
KAction* m_deleteColumn;
KAction* m_hideColumn;
KAction* m_showColumn;
KAction* m_showSelColumns;
KAction* m_insertColumn;
KAction* m_deleteRow;
KAction* m_insertRow;
KAction* m_hideRow;
KAction* m_showRow;
KAction* m_showSelRows;
KSelectAction* m_formulaSelection;
KAction* m_sortDec;
KAction* m_sortInc;
TKSelectColorAction* m_textColor;
TKSelectColorAction* m_bgColor;
KAction* m_cellLayout;
KAction* m_hideTable;
KAction* m_showTable;
KAction* m_borderLeft;
KAction* m_borderRight;
KAction* m_borderTop;
KAction* m_borderBottom;
KAction* m_borderAll;
KAction* m_borderOutline;
KAction* m_borderRemove;
TKSelectColorAction* m_borderColor;
KAction* m_tableFormat;
// KAction* m_oszi;
KAction* m_autoSum;
KToggleAction* m_showPageBorders;
KActionMenu* m_scripts;
KAction* m_default;
KAction* m_areaName;
KAction* m_showArea;
KAction* m_resizeRow;
KAction* m_resizeColumn;
KAction* m_fontSizeUp;
KAction* m_fontSizeDown;
KAction* m_upper;
KAction* m_lower;
KAction* m_equalizeRow;
KAction* m_equalizeColumn;
KAction* m_preference;
KAction* m_firstLetterUpper;
KToggleAction* m_verticalText;
KAction* m_addModifyComment;
KAction* m_removeComment;
KAction* m_insertCell;
KAction* m_removeCell;
KAction* m_changeAngle;
KAction* m_mergeCell;
KAction* m_dissociateCell;
KAction* m_gotoCell;
KAction* m_increaseIndent;
KAction* m_decreaseIndent;
KAction* m_sortList;
KAction* m_spellChecking;
KAction* m_insertChartFrame;
KToggleAction* m_menuCalcMin;
KToggleAction* m_menuCalcMax;
KToggleAction* m_menuCalcAverage;
KToggleAction* m_menuCalcCount;
KToggleAction* m_menuCalcSum;
KToggleAction* m_menuCalcNone;
KoPartSelectAction *m_insertPart;
// Spell-checking
QStringList m_ignoreWord;
struct
{
KSpreadSpell * kspell;
KSpreadTable * firstSpellTable;
KSpreadTable * currentSpellTable;
KSpreadCell * currentCell;
unsigned int spellCurrCellX;
unsigned int spellCurrCellY;
unsigned int spellStartCellX;
unsigned int spellStartCellY;
unsigned int spellEndCellX;
unsigned int spellEndCellY;
bool spellCheckSelection;
QStringList ignoreWord;
// KMacroCommand * macroCmdSpellCheck;
} m_spell;
bool spellSwitchToOtherTable();
void spellCleanup();
/**
* Pointer to the last popup menu.
* Since only one popup menu can be opened at once, its pointer is stored here.
* Delete the old one before you store a pointer to anotheron here.
* May be 0L.
*/
QPopupMenu *m_pPopupMenu;
int m_popupMenuFirstToolId;
QPopupMenu *m_pPopupRow;
QPopupMenu *m_pPopupColumn;
/**
* Used for embedded children.
*/
QPopupMenu* m_popupChild;
/**
* used for list of choose
*/
QPopupMenu* m_popupListChoose;
/**
* Holds a pointer of the child for which the popup menu has been opened.
*/
KSpreadChild* m_popupChildObject;
/**
* This DCOP object represents the view.
*/
DCOPObject* m_dcop;
/**
* Tells whether the user modfied the current cell.
* Some key events are passed to the @ref EditWindow. When this flag is set and you
* want to leave the cell with the marker then you must first save the new text
* in the cell before moving the marker.
*/
bool m_bEditDirtyFlag;
/**
* The active KSpreadTable. This table has the input focus. It may be 0L, too.
*/
KSpreadTable* m_pTable;
KSpreadDoc *m_pDoc;
/**
* Flags that indicate whether we should display additional
* GUI stuff like rulers and scrollbars.
*
* @see #showGUI
*/
bool m_bShowGUI;
/**
* If @ref #updateEditWidget is called it changes some KToggleActions.
* That causes them to emit a signal. If this lock is TRUE, then these
* signals are ignored.
*/
bool m_toolbarLock;
struct ToolEntry
{
QString command;
KDataToolInfo info;
};
QPtrList m_lstTools;
static KSpreadScripts *m_pGlobalScriptsDialog;
//used to allow to refresh menubar
//otherwise kspread crash when I try to refresh menubar
//when I start kspread
bool m_bLoading;
/**
* Holds a guarded pointer to the transformation toolbox.
*/
QGuardedPtr m_transformToolBox;
/**
* Find and Replace context. We remember the options and the strings used
* previously.
*/
long m_findOptions;
QStringList m_findStrings;
QStringList m_replaceStrings;
KStatusBarLabel* m_sbCalcLabel;
/* helper functions */
void initializeCalcActions();
void initializeInsertActions();
void initializeEditActions();
void initializeAreaOperationActions();
void initializeGlobalOperationActions();
void initializeCellOperationActions();
void initializeCellPropertyActions();
void initializeTextFormatActions();
void initializeTextLayoutActions();
void initializeTextPropertyActions();
void initializeTableActions();
void initializeSpellChecking();
void initializeRowColumnActions();
void initializeBorderActions();
};
#endif