Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

memorystatus.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #include "memorystatus.h"
00021 #include "memory.h"
00022 #include "swapfile.h"
00023 
00024 #include <qpainter.h>
00025 #include <qpushbutton.h>
00026 #include <qdrawutil.h>
00027 #include <qlabel.h>
00028 
00029 #include <qlayout.h>
00030 
00031 using namespace Opie::Ui;
00032 MemoryStatus::MemoryStatus(QWidget *parent, WFlags f )
00033     : QFrame(parent, 0, f), mi(0), sf(0)
00034 {
00035     setCaption( tr("Memory Status") );
00036     //resize( 220, 180 );
00037 
00038     QVBoxLayout *lay = new QVBoxLayout( this );
00039     tab = new OTabWidget( this, "tabwidget", OTabWidget::Global );
00040     lay->addWidget( tab );
00041     tab->addTab( mi = new MemoryInfo( tab ), "memory/memorytabicon", tr("Memory") );
00042     tab->addTab( sf = new Swapfile( tab ), "memory/storagetabicon", tr("Swapfile") );
00043 
00044     QLabel* about = new QLabel(tr("<center><b>Memory Monitor Plugin</b><br>"
00045         "Copyright (C) 2003 Anton Maslovsky<br>"
00046         "&lt;<a href=\"mailto:my-zaurus@narod.ru\">my-zaurus@narod.ru</a>&gt;<br>"
00047         "<a href=\"http://my-zaurus.narod.ru\">http://my-zaurus.narod.ru</a><br>"
00048         "Based on source code from:<br> qswap (udoseidel@gmx.de) <br> Battery Applet (trolltech.com) <br> SysInfo (OPIE)<br><br>"
00049         "This program is licensed under GNU GPL.</center>"), tab);
00050 
00051     tab->addTab( about, "memory/info", tr("About") );
00052 
00053     tab->setCurrentTab( tr( "Memory" ) );
00054 }
00055 
00056 int MemoryStatus::percent()
00057 {
00058     if (mi == 0)
00059         return 100;
00060 
00061     int total = mi->total;
00062     if (mi->swaptotal > 0)
00063         total += mi->swaptotal;
00064 
00065     int used = mi->realUsed;
00066     if (mi->swapused > 0)
00067         total += mi->swapused;
00068 
00069     return ((total - used) * 100)/total;
00070 }
00071 
00072 QSize MemoryStatus::sizeHint() const
00073 {
00074     QSize s = tab->size();
00075     s.setWidth(200);
00076     s.setHeight((mi->swaptotal > 0) ? 220 : 200);
00077     return s;
00078 }
00079 
00080 MemoryStatus::~MemoryStatus()
00081 {
00082 }

Generated on Sat Nov 5 16:16:44 2005 for OPIE by  doxygen 1.4.2