~ubuntu-branches/ubuntu/karmic/kst/karmic

« back to all changes in this revision

Viewing changes to kst/src/libkstapp/kst.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-28 15:16:16 UTC
  • mfrom: (1.2.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080628151616-9hvxg0nmnlkmyz4y
Tags: 1.6.0-1
* New upstream release.
* Change B-D to libnetcdf-dev.
* Add dh_icons call.  Closes: #457853.
* Bump Standards-Version to 3.8.0.
* Bump debhelper dependency for dh_icons.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
#include "kstsettingsdlg_i.h"
84
84
#include "kstuinames.h"
85
85
#include "kstvectordefaults.h"
 
86
#include "kstvectorsavedialog_i.h"
86
87
#include "kstvectordialog_i.h"
87
88
#include "kstviewmanager_i.h"
88
89
#include "kstviewscalarsdialog_i.h"
90
91
#include "kstviewvectorsdialog_i.h"
91
92
#include "kstviewmatricesdialog_i.h"
92
93
#include "kstviewfitsdialog_i.h"
 
94
#include "kstviewwidget.h"
93
95
#include "kstviewwindow.h"
94
96
#include "plotmimesource.h"
95
97
#include "plugincollection.h"
98
100
#include "statuslabel.h"
99
101
#include "sysinfo.h"
100
102
#include "updatethread.h"
101
 
#include "vectorsavedialog.h"
102
103
#include "kstobjectdefaults.h"
103
104
 
104
105
#define MODE_BUTTON_ID       5
161
162
  differentiateCurvesDialog = new KstCurveDifferentiateI(this);
162
163
  changeNptsDialog = new KstChangeNptsDialogI(this);
163
164
  graphFileDialog = new KstGraphFileDialogI(this);
164
 
  vectorSaveDialog = new VectorSaveDialog(this);
 
165
  vectorSaveDialog = new KstVectorSaveDialogI(this);
165
166
  _monochromeDialog = new KstMonochromeDialogI(this);
166
167
#ifdef KST_QUICKSTART_DLG
167
168
  _quickStartDialog = new KstQuickStartDialogI(this, 0 , true);
794
795
  _gfxPictureAction->setExclusiveGroup("gfx");
795
796
  _gfxPictureAction->setToolTip(i18n("Insert picture"));
796
797
  _gfxPictureAction->setWhatsThis(i18n("Insert picture"));
797
 
  
 
798
 
798
799
  _gfx2DPlotAction = new KRadioAction(i18n("&Plot"), "kst_newplot",
799
800
                                   KShortcut(CTRL+Key_2),
800
801
                                   this, SLOT(toggleMouseMode()),
811
812
  _gfxArrowAction->setToolTip(i18n("Draw arrow"));
812
813
  _gfxArrowAction->setWhatsThis(i18n("Draw arrow"));
813
814
 
 
815
  _gfxLegendAction = new KRadioAction(i18n("&Legend"), "kst_gfx_legend",
 
816
                                   KShortcut(CTRL+Key_3),
 
817
                                   this, SLOT(toggleMouseMode()),
 
818
                                   actionCollection(), "legend_action");
 
819
  _gfxLegendAction->setExclusiveGroup("gfx");
 
820
  _gfxLegendAction->setToolTip(i18n("Insert Legend"));
 
821
  _gfxLegendAction->setWhatsThis(i18n("Insert Legend"));
 
822
 
814
823
  _gfxLineAction = new KRadioAction(i18n("&Line"), "kst_gfx_line",
815
824
                                   KShortcut(Key_F10),
816
825
                                   this, SLOT(toggleMouseMode()),
853
862
  _gfxArrowAction->plug(mouseModeMenu);
854
863
  _gfxPictureAction->plug(mouseModeMenu);
855
864
  _gfx2DPlotAction->plug(mouseModeMenu);
 
865
  _gfxLegendAction->plug(mouseModeMenu);
856
866
 
857
867
  toolBar()->insertButton("thumbnail", MODE_BUTTON_ID, mouseModeMenu, true, i18n("Select the desired mode"));
858
868
  toggleMouseMode();
969
979
void KstApp::selectDataPlugin() {
970
980
  QStringList l;
971
981
 
972
 
  // the new KstDataObject plugins...
973
 
  QStringList newPlugins;
 
982
  // the KstDataObject plugins...
 
983
  QStringList dataObjectPlugins;
974
984
  const KstPluginInfoList pluginInfo = KstDataObject::pluginInfoList();
975
985
  {
976
986
    KstPluginInfoList::ConstIterator it = pluginInfo.begin();
977
987
    for (; it != pluginInfo.end(); ++it) {
978
 
      newPlugins << it.key();
 
988
      dataObjectPlugins << it.key();
979
989
    }
980
990
  }
981
991
 
982
 
  l += newPlugins;
 
992
  l += dataObjectPlugins;
983
993
 
984
 
  // the old C style plugins...
985
 
  QStringList oldPlugins;
 
994
  // the C-style plugins...
 
995
  QStringList cPlugins;
986
996
  const QMap<QString,QString> readable = PluginCollection::self()->readableNameList();
987
997
  {
988
998
    QMap<QString,QString>::const_iterator it = readable.begin();
989
999
    for (; it != readable.end(); ++it) {
990
 
      oldPlugins << it.key();
 
1000
      cPlugins << it.key();
991
1001
    }
992
1002
  }
993
1003
 
994
 
  l += oldPlugins;
 
1004
  l += cPlugins;
995
1005
 
996
 
  // list the old and new stlye plugins together in ascending alphabetical order...
 
1006
  //
 
1007
  // list the KstDataObject and C-style plugins together in ascending alphabetical order...
 
1008
  //
997
1009
  l.sort();
998
1010
 
999
1011
  bool ok = false;
1002
1014
  if (ok && !plugin.isEmpty()) {
1003
1015
    const QString p = plugin.join("");
1004
1016
 
1005
 
    if (newPlugins.contains(p)) {
 
1017
    if (dataObjectPlugins.contains(p)) {
1006
1018
      KstDataObjectPtr ptr = KstDataObject::plugin(p);
1007
1019
      ptr->showDialog(true);
1008
 
    } else if (oldPlugins.contains(p)) {
 
1020
    } else if (cPlugins.contains(p)) {
1009
1021
      KstPluginDialogI::globalInstance()->showNew(readable[p]);
1010
1022
    }
1011
1023
  }
1066
1078
  }
1067
1079
 
1068
1080
  opening = true;
 
1081
 
1069
1082
  KURL url;
1070
1083
  bool rc = false;
1071
1084
 
1081
1094
    setCaption(doc->title());
1082
1095
    if (url.isLocalFile()) {
1083
1096
      QFileInfo finfo(in_filename);
1084
 
      addRecentFile(finfo.absFilePath());
 
1097
      QString fileExport;
 
1098
 
 
1099
      fileExport = finfo.absFilePath();
 
1100
      addRecentFile(fileExport);
 
1101
      if (fileExport.endsWith(QString(".kst"), FALSE)) {
 
1102
        fileExport.truncate(fileExport.length() - QString(".kst").length());
 
1103
      }
 
1104
      graphFileDlg()->setURL(fileExport);
1085
1105
    } else {
1086
1106
      addRecentFile(url);
1087
1107
    }
 
1108
 
1088
1109
    rc = true;
1089
1110
  }
 
1111
 
1090
1112
  slotUpdateStatusMsg(i18n("Ready"));
1091
1113
  opening = false;
 
1114
 
1092
1115
  return rc;
1093
1116
}
1094
1117
 
1850
1873
    action = _gfxArrowAction;
1851
1874
    mode = KstTopLevelView::CreateMode;
1852
1875
    createType = "Arrow";
 
1876
  } else if (_gfxLegendAction->isChecked()) {
 
1877
    action = _gfxLegendAction;
 
1878
    mode = KstTopLevelView::CreateMode;
 
1879
    createType = "Legend";
1853
1880
  } else if (LayoutAction->isChecked()) {
1854
1881
    action = LayoutAction;
1855
1882
    mode = KstTopLevelView::LayoutMode;
2057
2084
 
2058
2085
 
2059
2086
void KstApp::updateDataDialogs(bool dm, bool vm) {
2060
 
 
2061
2087
  ViewScalarsDialogAction->setEnabled(viewScalarsDialog->hasContent());
2062
2088
  ViewStringsDialogAction->setEnabled(viewStringsDialog->hasContent());
2063
2089
  ViewVectorsDialogAction->setEnabled(viewVectorsDialog->hasContent());
2533
2559
void KstApp::updateMemoryStatus() {
2534
2560
#ifdef HAVE_LINUX
2535
2561
  meminfo();
 
2562
 
 
2563
  QString memoryAvailable;
2536
2564
  unsigned long mi = S(kb_main_free + kb_main_buffers + kb_main_cached);
2537
 
  slotUpdateMemoryMsg(i18n("%1 MB available").arg(mi / (1024 * 1024)));
 
2565
 
 
2566
  mi /= 1024;
 
2567
  if (mi < 1024) {
 
2568
    memoryAvailable = i18n("abbreviation for kilobytes", "%1 kB").arg(mi);
 
2569
  } else {
 
2570
    mi /= 1024;
 
2571
    if (mi < 1024) {
 
2572
      memoryAvailable = i18n("abbreviation for megabytes", "%1 MB").arg(mi);
 
2573
    } else {
 
2574
      mi /= 1024;
 
2575
      if (mi < 1024) {
 
2576
        memoryAvailable = i18n("abbreviation for gigabytes", "%1 GB").arg(mi);
 
2577
      } else {
 
2578
        mi /= 1024;
 
2579
        memoryAvailable = i18n("abbreviation for terabytes", "%1 TB").arg(mi);
 
2580
      }
 
2581
    }
 
2582
  }
 
2583
 
 
2584
  slotUpdateMemoryMsg(i18n("%1 available").arg(memoryAvailable));
2538
2585
#endif
2539
2586
}
2540
2587