[Kst] branches/work/kst/1.6/kst/src/libkstapp
Andrew Walker
arwalker at sumusltd.com
Mon Sep 24 19:13:51 CEST 2007
SVN commit 716408 by arwalker:
BUG:150071 display memory available in appropriate memory units
M +35 -12 kst.cpp
M +39 -2 kstdatawizard_i.cpp
--- branches/work/kst/1.6/kst/src/libkstapp/kst.cpp #716407:716408
@@ -969,31 +969,33 @@
void KstApp::selectDataPlugin() {
QStringList l;
- // the new KstDataObject plugins...
- QStringList newPlugins;
+ // the KstDataObject plugins...
+ QStringList dataObjectPlugins;
const KstPluginInfoList pluginInfo = KstDataObject::pluginInfoList();
{
KstPluginInfoList::ConstIterator it = pluginInfo.begin();
for (; it != pluginInfo.end(); ++it) {
- newPlugins << it.key();
+ dataObjectPlugins << it.key();
}
}
- l += newPlugins;
+ l += dataObjectPlugins;
- // the old C style plugins...
- QStringList oldPlugins;
+ // the C-style plugins...
+ QStringList cPlugins;
const QMap<QString,QString> readable = PluginCollection::self()->readableNameList();
{
QMap<QString,QString>::const_iterator it = readable.begin();
for (; it != readable.end(); ++it) {
- oldPlugins << it.key();
+ cPlugins << it.key();
}
}
- l += oldPlugins;
+ l += cPlugins;
- // list the old and new stlye plugins together in ascending alphabetical order...
+ //
+ // list the KstDataObject and C-style plugins together in ascending alphabetical order...
+ //
l.sort();
bool ok = false;
@@ -1002,10 +1004,10 @@
if (ok && !plugin.isEmpty()) {
const QString p = plugin.join("");
- if (newPlugins.contains(p)) {
+ if (dataObjectPlugins.contains(p)) {
KstDataObjectPtr ptr = KstDataObject::plugin(p);
ptr->showDialog(true);
- } else if (oldPlugins.contains(p)) {
+ } else if (cPlugins.contains(p)) {
KstPluginDialogI::globalInstance()->showNew(readable[p]);
}
}
@@ -2533,8 +2535,29 @@
void KstApp::updateMemoryStatus() {
#ifdef HAVE_LINUX
meminfo();
+
+ QString memoryAvailable;
unsigned long mi = S(kb_main_free + kb_main_buffers + kb_main_cached);
- slotUpdateMemoryMsg(i18n("%1 MB available").arg(mi / (1024 * 1024)));
+
+ mi /= 1024;
+ if (mi < 1024) {
+ memoryAvailable = i18n("abbreviation for kilobytes", "%1 kB").arg(mi);
+ } else {
+ mi /= 1024;
+ if (mi < 1024) {
+ memoryAvailable = i18n("abbreviation for megabytes", "%1 MB").arg(mi);
+ } else {
+ mi /= 1024;
+ if (mi < 1024) {
+ memoryAvailable = i18n("abbreviation for gigabytes", "%1 GB").arg(mi);
+ } else {
+ mi /= 1024;
+ memoryAvailable = i18n("abbreviation for terabytes", "%1 TB").arg(mi);
+ }
+ }
+ }
+
+ slotUpdateMemoryMsg(i18n("%1 available").arg(memoryAvailable));
#endif
}
--- branches/work/kst/1.6/kst/src/libkstapp/kstdatawizard_i.cpp #716407:716408
@@ -701,8 +701,45 @@
ds->unlock();
if (memoryRequested > memoryAvailable) {
- KMessageBox::sorry(this, i18n("You requested to read in %1 MB of data but it seems that you only have approximately %2 MB of usable memory available. You cannot load this much data.").arg(memoryRequested/(1024*1024)).arg(memoryAvailable/(1024*1024)));
- rc = false;
+ QString strMemoryRequested;
+ QString strMemoryAvailable;
+
+ memoryRequested /= 1024;
+ memoryAvailable /= 1024;
+ if (memoryRequested < 10 * 1024) {
+ strMemoryRequested = i18n("abbreviation for kilobytes", "%1 kB").arg(memoryRequested);
+ strMemoryAvailable = i18n("abbreviation for kilobytes", "%1 kB").arg(memoryAvailable);
+ } else {
+ memoryRequested /= 1024;
+ memoryAvailable /= 1024;
+ if (memoryRequested < 10 * 1024) {
+ strMemoryRequested = i18n("abbreviation for megabytes", "%1 MB").arg(memoryRequested);
+ strMemoryAvailable = i18n("abbreviation for megabytes", "%1 MB").arg(memoryAvailable);
+ } else {
+ memoryRequested /= 1024;
+ memoryAvailable /= 1024;
+ if (memoryRequested < 10 * 1024) {
+ strMemoryRequested = i18n("abbreviation for gigabytes", "%1 GB").arg(memoryRequested);
+ strMemoryAvailable = i18n("abbreviation for gigabytes", "%1 GB").arg(memoryAvailable);
+ } else {
+ memoryRequested /= 1024;
+ memoryAvailable /= 1024;
+ strMemoryRequested = i18n("abbreviation for terabytes", "%1 TB").arg(memoryRequested);
+ strMemoryAvailable = i18n("abbreviation for terabytes", "%1 TB").arg(memoryAvailable);
+ }
+ }
+ }
+
+ if (strMemoryRequested != strMemoryAvailable) {
+ KMessageBox::sorry(this, i18n("You requested to read in over %1 of data but it seems that you have approximately only %2 of usable memory available. You cannot load this much data.").arg(strMemoryRequested).arg(strMemoryAvailable));
+ rc = false;
+ } else {
+ if (KMessageBox::questionYesNo(this, i18n("You requested to read in approximately %1 of data but it seems that you have slightly less usable memory than this available. Would you like to try and load the data anyway?").arg(strMemoryRequested)) == KMessageBox::Yes) {
+ rc = true;
+ } else {
+ rc = false;
+ }
+ }
}
return rc;
More information about the Kst
mailing list