00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "kalzium.h"
00014
00015 #include <kapplication.h>
00016 #include <element.h>
00017 #include <kdeeduglossary.h>
00018 #include <kactioncollection.h>
00019 #include "prefs.h"
00020 #include "ui_settings_colors.h"
00021 #include "ui_settings_misc.h"
00022 #include "ui_settings_units.h"
00023 #include "elementdataviewer.h"
00024 #include "detailinfodlg.h"
00025 #include "periodictableview.h"
00026 #include "molcalcwidget.h"
00027 #include "detailedgraphicaloverview.h"
00028 #include "somwidget_impl.h"
00029 #include "timewidget_impl.h"
00030 #include "kalziumdataobject.h"
00031 #include "nuclideboard.h"
00032 #include "kalziumnumerationtype.h"
00033 #include "kalziumschemetype.h"
00034 #include "kalziumgradienttype.h"
00035 #include "kalziumtabletype.h"
00036 #include "rsdialog.h"
00037 #include "tablesdialog.h"
00038 #include "legendwidget.h"
00039
00040
00041
00042 #include "search.h"
00043 #include "searchwidget.h"
00044
00045 #include <config-kalzium.h>
00046
00047 #ifdef HAVE_FACILE
00048 #include "eqchemview.h"
00049 #endif
00050
00051 #ifdef HAVE_OPENBABEL2
00052 #ifdef HAVE_EIGEN
00053 #include "tools/moleculeview.h"
00054 #endif
00055 #include "tools/obconverter.h"
00056 #endif
00057
00058 #include <QDockWidget>
00059 #include <QLayout>
00060 #include <QToolBox>
00061 #include <QScrollArea>
00062 #include <QKeyEvent>
00063 #include <QTimer>
00064 #include <QTabWidget>
00065 #include <QSvgGenerator>
00066 #include <QRegExp>
00067
00068 #include <kmessagebox.h>
00069 #include <kconfigdialog.h>
00070 #include <kiconloader.h>
00071 #include <kdebug.h>
00072 #include <kaction.h>
00073 #include <kparts/part.h>
00074 #include <kselectaction.h>
00075 #include <kstatusbar.h>
00076 #include <kstandarddirs.h>
00077 #include <kstandardaction.h>
00078 #include <kicon.h>
00079 #include <kservicetypetrader.h>
00080 #include <kurl.h>
00081 #include <kfiledialog.h>
00082 #include <KLocale>
00083 #include <KPluginLoader>
00084
00085
00086
00087 #define PeriodicTableView_MARGIN 5
00088 #define IDS_ELEMENTINFO 7
00089
00090 Kalzium::Kalzium()
00091 : KXmlGuiWindow( 0 )
00092 {
00093 setObjectName( "KalziumMainWindow" );
00094
00095
00096 KGlobal::locale()->insertCatalog( "libkdeedu" );
00097
00098
00099 KalziumDataObject::instance();
00100
00101 Search *newsearch = new Search();
00102 KalziumDataObject::instance()->setSearch( newsearch );
00103 connect( newsearch, SIGNAL( searchChanged() ), this, SLOT( slotSearchElements() ) );
00104 connect( newsearch, SIGNAL( searchReset() ), this, SLOT( slotSearchElements() ) );
00105
00106 QWidget *fakemain = new QWidget( this );
00107 QVBoxLayout *fakelay = new QVBoxLayout( fakemain );
00108 fakelay->setMargin( 0 );
00109 fakelay->setSpacing( 2 );
00110
00111 m_searchWidget = new SearchWidget( fakemain );
00112 fakelay->addWidget( m_searchWidget );
00113
00114 QScrollArea *helperSV = new QScrollArea( fakemain );
00115 m_PeriodicTableView = new PeriodicTableView( helperSV->viewport() );
00116 m_PeriodicTableView->setObjectName( "PeriodicTableView" );
00117 helperSV->setWidget( m_PeriodicTableView );
00118 helperSV->setFrameShape( QFrame::NoFrame );
00119 fakelay->addWidget( helperSV );
00120
00121 m_legendWidget = new LegendWidget( this );
00122 connect( m_PeriodicTableView, SIGNAL(ModeChanged( KalziumPainter::MODE) ),
00123 m_legendWidget, SLOT(setMode(KalziumPainter::MODE) ) );
00124 connect( m_PeriodicTableView, SIGNAL(TableTypeChanged( KalziumTableType* ) ),
00125 m_legendWidget, SLOT( setTableType( KalziumTableType * ) ) );
00126 connect( m_PeriodicTableView, SIGNAL(GradientTypeChanged( KalziumGradientType* ) ),
00127 m_legendWidget, SLOT( setGradientType( KalziumGradientType * ) ) );
00128 connect( m_PeriodicTableView, SIGNAL( SchemeChanged( KalziumSchemeType * ) ),
00129 m_legendWidget, SLOT( setScheme( KalziumSchemeType * ) ) );
00130
00131
00132
00133
00134
00135
00136 m_infoDialog = 0;
00137 m_toolboxCurrent = 0;
00138 m_prevNormalMode = KalziumPainter::NORMAL;
00139
00140 connect( m_PeriodicTableView, SIGNAL( ElementClicked( int ) ), this, SLOT( openInformationDialog( int ) ));
00141 connect( m_PeriodicTableView, SIGNAL( MouseOver( int ) ), this, SLOT( elementHover( int ) ));
00142
00143
00144 setCentralWidget( fakemain );
00145
00146 setupSidebars();
00147 setupActions();
00148
00149
00150
00151 m_glossarydlg = new GlossaryDialog( this );
00152 m_glossarydlg->setObjectName( QLatin1String( "glossary" ) );
00153 QString dir = KGlobal::dirs()->findResourceDir( "data", "kalzium/data/" );
00154 QString picturepath = dir + "kalzium/data/bg.jpg";
00155 KUrl u = KUrl::fromPath( dir + "kalzium/data/knowledge.xml" );
00156 Glossary *g = new Glossary( u );
00157 g->setName( i18n( "Knowledge" ) );
00158 g->setBackgroundPicture( picturepath );
00159 m_glossarydlg->addGlossary( g, true );
00160 u = KUrl::fromPath( dir + "kalzium/data/tools.xml" );
00161 g = new Glossary( u, dir + "kalzium/data/toolpics/" );
00162 g->setName( i18n( "Tools" ) );
00163 g->setBackgroundPicture( picturepath );
00164 m_glossarydlg->addGlossary( g, true );
00165
00166 setupStatusBar();
00167 }
00168
00169 static QStringList prependToListItems( const QStringList& list, const KLocalizedString& strprefix )
00170 {
00171 QStringList l;
00172 for ( int i = 0; i < list.count(); i++ )
00173 l << strprefix.subs( list.at( i ) ).toString();
00174 return l;
00175 }
00176
00177 void Kalzium::setupActions()
00178 {
00179
00180 QStringList looklist;
00181 QStringList schemes = KalziumSchemeTypeFactory::instance()->schemes();
00182 looklist << prependToListItems( schemes, ki18n( "Scheme: %1" ) );
00183 looklist << prependToListItems( KalziumGradientTypeFactory::instance()->gradients(), ki18n( "Gradient: %1" ) );
00184 look_action = actionCollection()->add<KSelectAction>( "view_look" );
00185 look_action->setText( i18n( "&Look" ) );
00186 look_action->setItems(looklist);
00187 connect( look_action, SIGNAL( triggered( int ) ), this, SLOT( slotSwitchtoLook( int ) ) );
00188
00189 look_action_schemes = actionCollection()->add<KSelectAction>( "view_look_onlyschemes" );
00190 look_action_schemes->setText( i18n( "&Scheme" ) );
00191 look_action_schemes->setItems( schemes );
00192 look_action_schemes->setToolBarMode( KSelectAction::MenuMode );
00193 look_action_schemes->setToolButtonPopupMode( QToolButton::InstantPopup );
00194 connect( look_action_schemes, SIGNAL( triggered( int ) ), this, SLOT( slotSwitchtoLook( int ) ) );
00195
00196
00197 QStringList tablelist;
00198 QStringList table_schemes = KalziumTableTypeFactory::instance()->tables();
00199 tablelist << prependToListItems( table_schemes, ki18n( "Table: %1" ) );
00200 table_action = actionCollection()->add<KSelectAction>( "view_table" );
00201 table_action->setText( i18n( "&Tables" ) );
00202 table_action->setItems(tablelist);
00203 table_action->setCurrentItem(Prefs::table());
00204 connect( table_action, SIGNAL( triggered( int ) ), this, SLOT( slotSwitchtoTable( int ) ) );
00205
00206
00207 numeration_action = actionCollection()->add<KSelectAction>( "view_numerationtype" );
00208 numeration_action->setText( i18n( "&Numeration" ) );
00209 numeration_action->setItems( KalziumNumerationTypeFactory::instance()->numerations() );
00210 numeration_action->setCurrentItem(Prefs::numeration());
00211 connect( numeration_action, SIGNAL( triggered( int ) ), this, SLOT( slotSwitchtoNumeration( int ) ) );
00212
00213 m_EQSolverAction = actionCollection()->addAction( "tools_eqsolver" );
00214 m_EQSolverAction->setText( i18n( "&Equation Solver..." ) );
00215 m_EQSolverAction->setIcon( KIcon( "eqchem" ) );
00216 m_EQSolverAction->setWhatsThis( i18nc( "WhatsThis Help", "This tool allows you to solve chemical equations." ) );
00217 #ifdef HAVE_FACILE
00218 connect( m_EQSolverAction, SIGNAL( triggered() ), this, SLOT( slotShowEQSolver() ) );
00219 m_EQSolverAction->setEnabled( true );
00220 #else
00221 m_EQSolverAction->setEnabled( false );
00222 #endif
00223
00224
00225 m_pPlotAction = actionCollection()->addAction( "tools_plotdata" );
00226 m_pPlotAction->setText( i18n( "&Plot Data..." ) );
00227 m_pPlotAction->setIcon( KIcon( "plot" ) );
00228 connect( m_pPlotAction, SIGNAL( triggered() ), this, SLOT( slotPlotData() ) );
00229
00230 m_pIsotopeTableAction= actionCollection()->addAction( "tools_isotopetable" );
00231 m_pIsotopeTableAction->setText( i18n( "&Isotope Table..." ) );
00232 m_pIsotopeTableAction->setIcon( KIcon( "isotopemap" ) );
00233 m_pIsotopeTableAction->setWhatsThis( i18nc( "WhatsThis Help", "This table shows all of the known isotopes of the chemical elements." ) );
00234 connect( m_pIsotopeTableAction, SIGNAL( triggered() ), this, SLOT( slotIsotopeTable() ) );
00235
00236 m_pGlossaryAction = actionCollection()->addAction( "tools_glossary" );
00237 m_pGlossaryAction->setText(i18n( "&Glossary..." ) );
00238 m_pGlossaryAction->setIcon( KIcon( "glossary" ) );
00239 connect( m_pGlossaryAction, SIGNAL( triggered() ), this, SLOT( slotGlossary() ) );
00240
00241 m_pRSAction = actionCollection()->addAction( "tools_rs" );
00242 m_pRSAction->setText( i18n( "&R/S Phrases..." ) );
00243 m_pRSAction->setIcon( KIcon( "kalzium_rs" ) );
00244 connect( m_pRSAction, SIGNAL( triggered() ), this, SLOT( slotRS() ) );
00245
00246 m_pOBConverterAction = actionCollection()->addAction( "tools_obconverter" );
00247 m_pOBConverterAction->setText( i18n( "Convert chemical files..." ) );
00248 m_pOBConverterAction->setIcon( KIcon( "kalzium_obconverter" ) );
00249 m_pOBConverterAction->setWhatsThis( i18nc( "WhatsThis Help", "With this tool, you can convert files containing chemical data between various file formats." ) );
00250 connect( m_pOBConverterAction, SIGNAL( triggered() ), this, SLOT( slotOBConverter() ) );
00251 #ifndef HAVE_OPENBABEL2
00252 m_pOBConverterAction->setEnabled( false );
00253 #endif
00254
00255 m_pMoleculesviewer = actionCollection()->addAction( "tools_moleculeviewer" );
00256 m_pMoleculesviewer->setText( i18n( "Molecular Viewer..." ) );
00257 m_pMoleculesviewer->setIcon( KIcon( "kalzium_molviewer" ) );
00258 m_pMoleculesviewer->setWhatsThis( i18nc( "WhatsThis Help", "This tool allows you to view 3D molecular structures." ) );
00259 connect( m_pMoleculesviewer, SIGNAL( triggered() ), this, SLOT( slotMoleculeviewer() ) );
00260 #if !defined(HAVE_OPENBABEL2) || !defined(HAVE_OPENGL) || !defined(HAVE_EIGEN)
00261 m_pMoleculesviewer->setEnabled( false );
00262 #endif
00263
00264 m_pTables = actionCollection()->addAction( "tools_tables" );
00265 m_pTables->setText( i18n( "&Tables..." ) );
00266 m_pTables->setIcon( KIcon( "kalzium_tables" ) );
00267 m_pTables->setWhatsThis(i18nc("WhatsThis Help", "This will open a dialog with listings of symbols and numbers related to chemistry."));
00268
00269 connect( m_pTables, SIGNAL( triggered() ), this, SLOT( slotTables() ) );
00270
00271
00272 m_pLegendAction = m_InfoDock->toggleViewAction();
00273 actionCollection()->addAction( "view_legend", m_pLegendAction );
00274 m_pLegendAction->setIcon( KIcon( "legend" ) );
00275 m_pLegendAction->setWhatsThis( i18nc( "WhatsThis Help", "This will show or hide the legend for the periodic table." ) );
00276 connect( m_pLegendAction, SIGNAL( triggered(bool) ),
00277 this, SLOT( slotShowLegend(bool) ) );
00278
00279 m_SidebarAction = m_dockWin->toggleViewAction();
00280 actionCollection()->addAction( "view_sidebar", m_SidebarAction );
00281 m_SidebarAction->setIcon( KIcon( "sidebar" ) );
00282 m_SidebarAction->setWhatsThis( i18nc( "WhatsThis Help", "This will show or hide a sidebar with additional information and a set of tools." ) );
00283 connect( m_SidebarAction, SIGNAL( triggered( bool ) ),
00284 this, SLOT( slotShowHideSidebar( bool ) ) );
00285
00286
00287
00288 KStandardAction::saveAs(this, SLOT(slotExportTable()), actionCollection());
00289 KStandardAction::preferences(this, SLOT(showSettingsDialog()), actionCollection());
00290 KStandardAction::quit( kapp, SLOT (closeAllWindows()),actionCollection() );
00291
00292 slotSwitchtoLook( Prefs::colorschemebox() );
00293 slotSwitchtoNumeration( Prefs::numeration() );
00294 slotSwitchtoTable( Prefs::table() );
00295 slotShowHideSidebar( m_SidebarAction->isChecked(), false );
00296 slotShowLegend( m_pLegendAction->isChecked(), false );
00297
00298
00299 setXMLFile("kalziumui.rc");
00300 setupGUI();
00301 }
00302
00303 void Kalzium::setupSidebars()
00304 {
00305 m_InfoDock = new QDockWidget( this );
00306 m_InfoDock->setObjectName( QLatin1String( "kalzium-infobar" ) );
00307 m_InfoDock->setAllowedAreas( Qt::BottomDockWidgetArea );
00308 m_InfoDock->setFeatures( QDockWidget::AllDockWidgetFeatures );
00309
00310 m_InfoDock->setWidget(m_legendWidget);
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 m_dockWin = new QDockWidget( this );
00321 m_dockWin->setObjectName( QLatin1String( "kalzium-sidebar" ) );
00322 m_dockWin->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
00323
00324 m_toolbox = new QToolBox( m_dockWin );
00325 m_dockWin->setWidget( m_toolbox );
00326
00327 QWidget *fake = new QWidget( m_toolbox );
00328 QVBoxLayout *lay = new QVBoxLayout( fake );
00329 lay->setMargin( 5 );
00330 lay->activate();
00331 m_detailWidget = new DetailedGraphicalOverview( fake );
00332 m_detailWidget->setObjectName( "DetailedGraphicalOverview" );
00333 m_detailWidget->setMinimumSize( 200, m_detailWidget->minimumSize().height() );
00334 connect( m_PeriodicTableView, SIGNAL( MouseOver( int ) ),
00335 m_detailWidget, SLOT( setElement( int ) ) );
00336 lay->addWidget( m_detailWidget );
00337 lay->addItem( new QSpacerItem( 10, 10, QSizePolicy::Fixed, QSizePolicy::MinimumExpanding ) );
00338 m_toolbox->addItem( fake, KIcon( "overview" ), i18n( "Overview" ) );
00339
00340 m_somWidget = new SOMWidgetIMPL( m_toolbox );
00341 m_somWidget->setObjectName( "somWidget" );
00342 connect( m_somWidget, SIGNAL( temperatureChanged( int ) ),
00343 m_PeriodicTableView, SLOT( setTemperature( int ) ) );
00344 m_toolbox->addItem( m_somWidget, KIcon( "statematter" ), i18n( "State of Matter" ) );
00345
00346 m_timeWidget = new TimeWidgetImpl( m_toolbox );
00347 m_timeWidget->setObjectName( "timeWidget" );
00348 connect( m_timeWidget->time_box, SIGNAL( valueChanged( int ) ),
00349 m_PeriodicTableView, SLOT( setTime( int ) ) );
00350 m_toolbox->addItem( m_timeWidget, KIcon( "timeline" ), i18n( "Timeline" ) );
00351
00352 m_calcWidget = new MolcalcWidget( m_toolbox );
00353 m_calcWidget->setObjectName( "molcalcwidget" );
00354 m_toolbox->addItem( m_calcWidget, KIcon( "calculate" ), i18n( "Calculate" ) );
00355
00356 connect( m_toolbox, SIGNAL( currentChanged( int ) ),
00357 this, SLOT( slotToolboxCurrentChanged( int ) ) );
00358
00359 addDockWidget( Qt::LeftDockWidgetArea, m_dockWin );
00360 addDockWidget( Qt::BottomDockWidgetArea, m_InfoDock );
00361 }
00362
00363 void Kalzium::slotExportTable()
00364 {
00365 QString fileName = KFileDialog::getSaveFileName(QString(), i18n("*.png *.xpm *.jpg *.svg"),
00366 this,
00367 i18n("Save Kalziums Table In"));
00368
00369 if (fileName.endsWith(".svg")) {
00370 m_PeriodicTableView->generateSvg( fileName );
00371 } else {
00372 QPixmap pix = QPixmap::grabWidget( m_PeriodicTableView );
00373 pix.save( fileName );
00374 }
00375 }
00376
00377 void Kalzium::slotGlossary()
00378 {
00379 m_glossarydlg->show();
00380 }
00381
00382 void Kalzium::slotRS()
00383 {
00384 RSDialog *rs = new RSDialog( this );
00385 rs->show();
00386 }
00387
00388 void Kalzium::slotOBConverter()
00389 {
00390 #ifdef HAVE_OPENBABEL2
00391 OBConverter * d = new OBConverter(this); d->show();
00392 #endif
00393 }
00394
00395 void Kalzium::slotMoleculeviewer()
00396 {
00397 #if defined(HAVE_OPENBABEL2) && defined(HAVE_OPENGL) && defined(HAVE_EIGEN)
00398
00399 if (!QGLFormat::hasOpenGL()) {
00400 KMessageBox::error(0, i18n("This system does not support OpenGL."), i18n("Kalzium Error"));
00401 return;
00402 }
00403
00404 MoleculeDialog * d = new MoleculeDialog( this ); d->show();
00405
00406 KPluginLoader loader("libkalziumglpart" );
00407 KPluginFactory* factory = loader.factory();
00408
00409 if (factory) {
00410 KParts::ReadOnlyPart *part = 0;
00411 part = static_cast<KParts::ReadOnlyPart*> ( factory->create( this, "KalziumGLPart" ) );
00412
00413 part->widget()->show();
00414 }
00415 #endif
00416 }
00417
00418 void Kalzium::slotTables()
00419 {
00420 TablesDialog *t = new TablesDialog( this );
00421 t->show();
00422 }
00423
00424 void Kalzium::slotShowEQSolver()
00425 {
00426 #ifdef HAVE_FACILE
00427 EQChemDialog *dlg = new EQChemDialog( this );
00428 dlg->show();
00429 #endif
00430 }
00431
00432 void Kalzium::slotIsotopeTable()
00433 {
00434 IsotopeTableDialog *ndialog = new IsotopeTableDialog( this );
00435 ndialog->show();
00436 }
00437
00438 void Kalzium::slotPlotData()
00439 {
00440 ElementDataViewer *edw = new ElementDataViewer( this );
00441 edw->show();
00442 }
00443
00444 void Kalzium::slotShowLegend( bool checked, bool changeconfig)
00445 {
00446 if ( !checked )
00447 {
00448 m_pLegendAction->setText( i18n( "Show &Legend") );
00449 }
00450 else
00451 {
00452 m_pLegendAction->setText( i18n( "Hide &Legend" ) );
00453 }
00454
00455 if ( changeconfig )
00456 {
00457 Prefs::setShowlegend( checked );
00458
00459 Prefs::self()->writeConfig();
00460 }
00461 }
00462
00463 void Kalzium::slotShowHideSidebar( bool checked, bool changeconfig )
00464 {
00465 if ( !checked )
00466 {
00467 m_SidebarAction->setText( i18n( "Show &Sidebar" ) );
00468 slotToolboxCurrentChanged( 0 );
00469 }
00470 else
00471 {
00472 m_SidebarAction->setText( i18n( "Hide &Sidebar" ) );
00473 slotToolboxCurrentChanged( m_toolboxCurrent );
00474 }
00475
00476 if ( changeconfig )
00477 {
00478 Prefs::setShowsidebar( checked );
00479
00480 Prefs::self()->writeConfig();
00481 }
00482 }
00483
00484 void Kalzium::slotSwitchtoTable( int index )
00485 {
00486 m_PeriodicTableView->slotChangeTable(index);
00487 if ( m_infoDialog )
00488 m_infoDialog->setTableType( m_PeriodicTableView->tableType() );
00489 Prefs::setTable(index);
00490 Prefs::self()->writeConfig();
00491 }
00492
00493 void Kalzium::slotSwitchtoNumeration( int index )
00494 {
00495 m_PeriodicTableView->setNumeration( index );
00496 Prefs::setNumeration(index);
00497 Prefs::self()->writeConfig();
00498 }
00499
00500 void Kalzium::slotSwitchtoLook( int which )
00501 {
00502 int id = which - KalziumSchemeTypeFactory::instance()->schemes().count();
00503 if ( id < 0 )
00504 {
00505 m_PeriodicTableView->activateColorScheme( which );
00506 if ( m_PeriodicTableView->mode() == KalziumPainter::GRADIENT )
00507 {
00508 m_PeriodicTableView->setMode( KalziumPainter::NORMAL );
00509 m_legendWidget->setMode( KalziumPainter::NORMAL );
00510 }
00511 }
00512 else
00513 {
00514 m_PeriodicTableView->setGradient( id );
00515 if ( m_PeriodicTableView->mode() == KalziumPainter::NORMAL )
00516 {
00517 m_PeriodicTableView->setMode( KalziumPainter::GRADIENT );
00518 m_legendWidget->setMode( KalziumPainter::GRADIENT );
00519 }
00520 }
00521 look_action->blockSignals( true );
00522 look_action_schemes->blockSignals( true );
00523 look_action->setCurrentItem( which );
00524 look_action_schemes->setCurrentItem( which );
00525 look_action->blockSignals( false );
00526 look_action_schemes->blockSignals( false );
00527
00528 Prefs::setColorschemebox(which);
00529 Prefs::self()->writeConfig();
00530 }
00531
00532 void Kalzium::showSettingsDialog()
00533 {
00534 if (KConfigDialog::showDialog("settings"))
00535 return;
00536
00537
00538 KConfigDialog *dialog = new KConfigDialog(this,"settings", Prefs::self());
00539 connect( dialog, SIGNAL( settingsChanged( const QString &) ), this , SLOT( slotUpdateSettings() ) );
00540 connect( dialog, SIGNAL( settingsChanged( const QString &) ), m_somWidget, SLOT( reloadUnits() ) );
00541 connect( dialog, SIGNAL( settingsChanged( const QString &) ), m_legendWidget, SLOT( updateContent() ) );
00542
00543 Ui_setupColors ui_colors;
00544 QWidget *w_colors = new QWidget( 0 );
00545 w_colors->setObjectName( "colors_page" );
00546 ui_colors.setupUi( w_colors );
00547 dialog->addPage( w_colors, i18n( "Colors" ), "preferences-desktop-color" );
00548
00549 Ui_setupUnits ui_units;
00550 QWidget *w_units = new QWidget( 0 );
00551 w_units->setObjectName( "units_page" );
00552 ui_units.setupUi( w_units );
00553 dialog->addPage( w_units, i18n( "Units" ), "system-run" );
00554
00555 Ui_setupMisc ui_misc;
00556 QWidget *w_misc = new QWidget( 0 );
00557 w_misc->setObjectName( "miscpage" );
00558 ui_misc.setupUi( w_misc );
00559 dialog->addPage( w_misc, i18n( "Miscellaneous" ), "preferences-other" );
00560
00561 dialog->show();
00562 }
00563
00564 void Kalzium::slotUpdateSettings()
00565 {
00566 }
00567
00568 void Kalzium::setupStatusBar()
00569 {
00570 statusBar()->insertItem( "", 0, 0 );
00571 statusBar()->setItemAlignment( 0, Qt::AlignRight );
00572
00573 statusBar()->insertItem( "" , IDS_ELEMENTINFO, 1 );
00574 statusBar()->setItemAlignment( IDS_ELEMENTINFO, Qt::AlignRight );
00575 statusBar()->show();
00576 }
00577
00578 void Kalzium::elementHover( int num )
00579 {
00580
00581
00582
00583
00584 Element *e = KalziumDataObject::instance()->element( num );
00585 statusBar()->changeItem( i18nc( "For example: \"Carbon (6), Mass: 12.0107 u\"", "%1 (%2), Mass: %3 u" ,
00586 e->dataAsString( ChemicalDataObject::name ) ,
00587 e->dataAsString( ChemicalDataObject::atomicNumber ) ,
00588 e->dataAsString( ChemicalDataObject::mass ) ) , IDS_ELEMENTINFO );
00589
00590 m_detailWidget->setBackgroundColor( m_PeriodicTableView->brushForElement( num ).color() );
00591 }
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616 void Kalzium::openInformationDialog( int number )
00617 {
00618 if (m_infoDialog)
00619 m_infoDialog->setElement( number );
00620 else
00621 {
00622 m_infoDialog = new DetailedInfoDlg(number, this );
00623
00624
00625 connect(m_infoDialog, SIGNAL(hidden()),
00626 m_PeriodicTableView, SLOT(unSelect()));
00627 connect(m_infoDialog, SIGNAL(elementChanged(int)),
00628 m_PeriodicTableView, SLOT(selectElement(int)));
00629 }
00630 m_infoDialog->setOverviewBackgroundColor( m_PeriodicTableView->brushForElement( number ).color() );
00631 m_infoDialog->setTableType( m_PeriodicTableView->tableType() );
00632 m_infoDialog->show();
00633 }
00634
00635 void Kalzium::slotToolboxCurrentChanged( int id )
00636 {
00637 KalziumPainter::MODE cur = m_PeriodicTableView->mode();
00638 if ( ( id > 1 ) && ( cur == KalziumPainter::NORMAL ) || ( cur == KalziumPainter::GRADIENT ) )
00639 m_prevNormalMode = cur;
00640 m_PeriodicTableView->setMode( m_prevNormalMode );
00641 m_legendWidget->setMode( m_prevNormalMode );
00642
00643
00644
00645 switch ( id )
00646 {
00647 case 0:
00648 m_searchWidget->setEnabled( true );
00649 break;
00650 case 1:
00651 m_PeriodicTableView->setTemperature( m_somWidget->temperature() );
00652 m_PeriodicTableView->setMode( KalziumPainter::SOM );
00653 m_legendWidget->setMode( KalziumPainter::SOM );
00654 m_searchWidget->setEnabled( true );
00655 break;
00656 case 2:
00657 m_PeriodicTableView->setTime( m_timeWidget->time_box->value() );
00658 m_PeriodicTableView->setMode( KalziumPainter::TIME );
00659 m_legendWidget->setMode( KalziumPainter::TIME );
00660 m_searchWidget->setEnabled( false );
00661 break;
00662 case 3:
00663 m_searchWidget->setEnabled( false );
00664 break;
00665 }
00666 if ( m_dockWin->isVisible() )
00667 m_toolboxCurrent = id;
00668 }
00669
00670 Kalzium::~Kalzium()
00671 {
00672 }
00673
00674 void Kalzium::keyPressEvent( QKeyEvent *e)
00675 {
00676 m_searchWidget->appendSearchText( e->text() );
00677 m_searchWidget->giveFocus();
00678 e->accept();
00679 }
00680
00681 void Kalzium::slotSearchElements()
00682 {
00683 m_PeriodicTableView->setFullDraw();
00684 m_PeriodicTableView->update();
00685 }
00686
00687 #include "kalzium.moc"