summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-05-10 14:46:02 (UTC)
committer mickeyl <mickeyl>2003-05-10 14:46:02 (UTC)
commit7d97fa637bb1af225b9e5075982b32718b0f78e4 (patch) (side-by-side diff)
treee06b9043c9fc3c0cf769986ea5e6a4983dbfe784
parent8bf3021bf5e86f7f6f6083606d77427adc8d13a7 (diff)
downloadopie-7d97fa637bb1af225b9e5075982b32718b0f78e4.zip
opie-7d97fa637bb1af225b9e5075982b32718b0f78e4.tar.gz
opie-7d97fa637bb1af225b9e5075982b32718b0f78e4.tar.bz2
- make oApp not return a const app object
- homogenize oconfig documentation - remove debug output
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/oapplication.h2
-rw-r--r--libopie2/opiecore/oconfig.h55
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp6
3 files changed, 20 insertions, 43 deletions
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h
index 1bd34e2..6bc2b1c 100644
--- a/libopie2/opiecore/oapplication.h
+++ b/libopie2/opiecore/oapplication.h
@@ -43,49 +43,49 @@ class OApplication: public QPEApplication
Q_OBJECT
public:
/**
* Constructor. Parses command-line arguments and sets the window caption.
*
* @param rAppName application name. Will be used for finding the
* associated message, icon and configuration files
*
*/
OApplication( int& argc, char** argv, const QCString& rAppName );
/**
* Destructor. Destroys the application object and its children.
*/
virtual ~OApplication();
/**
* @returns the process-wide application object
*
* This is similar to the global @ref QApplication pointer qApp. It
* allows access to the single global OApplication object, since
* more than one cannot be created in the same application. It
* saves you the trouble of having to pass the pointer explicitly
* to every function that may require it.
*/
- static const OApplication* oApplication() { return _instance; };
+ static OApplication* oApplication() { return _instance; };
/**
* Returns the application name as given during creation.
*
* @returns a reference to the application name
*/
const QCString& appName() const { return _appname; };
/**
* @returns the application session config object.
*
* @see OConfig
*/
OConfig* config();
/**
* Shows the main @a widget and sets the name of the application as window caption.
*/
virtual void showMainWidget( QWidget* widget, bool nomax = false );
/**
* Set the application title. The application title will be concatenated
* to the application name given in the constructor.
*
* @param title the title. If not given, resets caption to appname
*/
virtual void setTitle( const QString& title = QString::null ) const;
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h
index afe14b1..444d280 100644
--- a/libopie2/opiecore/oconfig.h
+++ b/libopie2/opiecore/oconfig.h
@@ -12,156 +12,129 @@
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program 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 OCONFIG_H
#define OCONFIG_H
//FIXME: Implement for X11 or reuse libqpe/Config there also?
+//FIXME: Or rather use QSettings also for libqpe?
#include <qpe/config.h>
class QColor;
class QFont;
/**
* A Configuration class based on the Qtopia @ref Config class
* featuring additional handling of color and font entries
*/
class OConfig : public Config
{
public:
-
/**
- * Constructs a OConfig object.
- *
- * @param name A file to parse.
+ * Constructs a OConfig object with a @a name.
*/
OConfig( const QString &name, Domain domain = User );
-
/**
* Destructs the OConfig object.
*
* Writes back any dirty configuration entries, and destroys
* dynamically created objects.
*/
virtual ~OConfig();
-
/**
- * Returns the name of the group in which we are
- * searching for keys and from which we are retrieving entries.
- *
- * @return The current group.
+ * @returns the name of the current group.
+ * The current group is used for searching keys and accessing entries.
*/
const QString& group() { return git.key(); };
-
/**
- * Reads a @ref QColor entry.
- *
- * Read the value of an entry specified by @p pKey in the current group
- * and interpret it as a color.
- *
- * @param pKey The key to search for.
- * @param pDefault A default value (null QColor by default) returned if the
- * key was not found or if the value cannot be interpreted.
- * @return The value for this key.
+ * @returns a @ref QColor entry or a @a default value if the key is not found.
*/
QColor readColorEntry( const QString& key, const QColor* pDefault ) const;
-
/**
- * Reads a @ref QFont value.
- *
- * Read the value of an entry specified by @p pKey in the current group
- * and interpret it as a font object.
- *
- * @param pKey The key to search for.
- * @param pDefault A default value (null QFont by default) returned if the
- * key was not found or if the read value cannot be interpreted.
- * @return The value for this key.
+ * @returns a @ref QFont value or a @a default value if the key is not found.
*/
QFont readFontEntry( const QString& key, const QFont* pDefault ) const;
-
};
/**
- * Helper class to facilitate working with @ref OConfig / @ref OSimpleConfig
- * groups.
+ * @brief Helper class for easier use of OConfig groups.
*
* Careful programmers always set the group of a
* @ref OConfig object to the group they want to read from
* and set it back to the old one of afterwards. This is usually
* written as:
* <pre>
*
* QString oldgroup config()->group();
* config()->setGroup( "TheGroupThatIWant" );
* ...
* config()->writeEntry( "Blah", "Blubb" );
*
* config()->setGroup( oldgroup );
* </pre>
*
* In order to facilitate this task, you can use
* OConfigGroupSaver. Simply construct such an object ON THE STACK
* when you want to switch to a new group. Then, when the object goes
* out of scope, the group will automatically be restored. If you
* want to use several different groups within a function or method,
* you can still use OConfigGroupSaver: Simply enclose all work with
* one group (including the creation of the OConfigGroupSaver object)
* in one block.
*
* @author Matthias Kalle Dalheimer <Kalle@kde.org>
* @version $Id$
* @see OConfig
- * @short Helper class for easier use of OConfig groups
*/
class OConfigGroupSaver
{
public:
/**
- * Constructor. You pass a pointer to the OConfigBase-derived
- * object you want to work with and a string indicating the _new_
- * group.
- * @param config The OConfig-derived object this
- * OConfigGroupSaver works on.
- * @param group The new group that the config object should switch to.
+ * Constructor.
+ * Create the object giving a @config object and a @a group to become
+ * the current group.
*/
OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() )
{ _config->setGroup( group ); }
OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group())
{ _config->setGroup( group ); }
OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group())
{ _config->setGroup( group ); }
-
+ /**
+ * Destructor.
+ * Restores the last current group.
+ */
~OConfigGroupSaver() { _config->setGroup( _oldgroup ); }
OConfig* config() { return _config; };
private:
OConfig* _config;
QString _oldgroup;
OConfigGroupSaver( const OConfigGroupSaver& );
OConfigGroupSaver& operator=( const OConfigGroupSaver& );
};
#endif // OCONFIG_H
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index c185fc5..c3c213c 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,42 +1,42 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "omanufacturerdb.h"
-// Qt
+/* QT */
#include <qstring.h>
#include <qfile.h>
#include <qtextstream.h>
OManufacturerDB* OManufacturerDB::_instance = 0;
OManufacturerDB* OManufacturerDB::instance()
{
if ( !OManufacturerDB::_instance )
{
qDebug( "OManufacturerDB::instance(): creating OManufacturerDB..." );
_instance = new OManufacturerDB();
}
return _instance;
}
OManufacturerDB::OManufacturerDB()
{
QString filename( "/etc/manufacturers" );
qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename );
if ( !QFile::exists( filename ) )
{
filename = "/opt/QtPalmtop/etc/manufacturers";
@@ -60,54 +60,58 @@ OManufacturerDB::OManufacturerDB()
QTextStream s( &file );
QString addr;
QString manu;
QString extManu;
while (!s.atEnd())
{
s >> addr;
if ( !addr ) // read nothing!?
{
continue;
}
else
if ( addr[0] == '#' )
{
continue;
}
s.skipWhiteSpace();
s >> manu;
s.skipWhiteSpace();
s >> extManu;
if ( extManu[0] == '#' ) // we have an extended manufacturer
{
s.skipWhiteSpace();
extManu = s.readLine();
+ #ifdef DEBUG
qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu );
+ #endif
manufacturersExt.insert( addr, extManu );
}
else
s.readLine();
+ #ifdef DEBUG
qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu );
+ #endif
manufacturers.insert( addr, manu );
}
}
}
OManufacturerDB::~OManufacturerDB()
{
}
const QString& OManufacturerDB::lookup( const QString& macaddr ) const
{
return manufacturers[macaddr.upper().left(8)];
}
const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
{
QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
}