summaryrefslogtreecommitdiffabout
path: root/microkde
Side-by-side diff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp7
-rw-r--r--microkde/kapplication.cpp15
-rw-r--r--microkde/kapplication.h1
-rw-r--r--microkde/kresources/factory.cpp6
4 files changed, 25 insertions, 4 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index c60b566..029f14b 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -67,97 +67,97 @@ static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit ri
KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o,
KDGanttMinimizeSplitter *parent, const char * name )
: QWidget( parent, name ), _activeButton( 0 ), _collapsed( false )
{
if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) {
mSizeHint = QSize(7,7);
mUseOffset = true;
} else {
mSizeHint = QSize(6,6);
mUseOffset = false;
}
s = parent;
setOrientation(o);
setMouseTracking( true );
mMouseDown = false;
//setMaximumHeight( 5 ); // test only
}
QSize KDGanttSplitterHandle::sizeHint() const
{
return mSizeHint;
}
void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
{
orient = o;
#ifndef QT_NO_CURSOR
if ( o == KDGanttMinimizeSplitter::Horizontal )
setCursor( splitHCursor );
else
setCursor( splitVCursor );
#endif
}
void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
{
updateCursor( e->pos() );
if ( !(e->state()&LeftButton) )
return;
if ( _activeButton != 0)
return;
QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
- mouseOffset;
- if ( true /*opaque()*/ ) {
+ if ( opaque() ) {
s->moveSplitter( pos, id() );
} else {
int min = pos; int max = pos;
s->getRange( id(), &min, &max );
s->setRubberband( QMAX( min, QMIN(max, pos )));
}
_collapsed = false;
}
void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
{
if ( e->button() == LeftButton ) {
_activeButton = onButton( e->pos() );
mouseOffset = s->pick(e->pos());
mMouseDown = true;
repaint();
updateCursor( e->pos() );
}
}
void KDGanttSplitterHandle::updateCursor( const QPoint& p)
{
if ( onButton( p ) != 0 ) {
setCursor( arrowCursor );
}
else {
if ( orient == KDGanttMinimizeSplitter::Horizontal )
setCursor( splitHCursor );
else
setCursor( splitVCursor );
}
}
void KDGanttSplitterHandle::toggle()
{
int pos;
int min, max;
if ( !_collapsed ) {
s->expandPos( id(), &min, &max );
if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
|| s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
pos = min;
}
else {
pos = max;
}
_origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
s->moveSplitter( pos, id() );
@@ -438,96 +438,101 @@ static QSize minSizeHint( const QWidget* w )
/*!
Constructs a horizontal splitter with the \a parent and \a
name arguments being passed on to the QFrame constructor.
*/
KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
:QFrame(parent,name,WPaintUnclipped)
{
mFirstHandle = 0;
#if QT_VERSION >= 232
orient = Horizontal;
init();
#endif
}
/*!
Constructs a splitter with orientation \a o with the \a parent
and \a name arguments being passed on to the QFrame constructor.
*/
KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
:QFrame(parent,name,WPaintUnclipped)
{
mFirstHandle = 0;
#if QT_VERSION >= 232
orient = o;
init();
#endif
}
/*!
Destroys the splitter and any children.
*/
KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
{
#if QT_VERSION >= 232
data->list.setAutoDelete( TRUE );
delete data;
#endif
}
#if QT_VERSION >= 232
void KDGanttMinimizeSplitter::init()
{
data = new QSplitterData;
if ( orient == Horizontal )
setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
else
setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
+#ifndef DESKTOP_VERSION
+ setOpaqueResize( false );
+#else
+ setOpaqueResize( true );
+#endif
}
#endif
void KDGanttMinimizeSplitter::toggle()
{
if ( mFirstHandle )
mFirstHandle->toggle();
else
qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available ");
}
/*!
\brief the orientation of the splitter
By default the orientation is horizontal (the widgets are side by side).
The possible orientations are Qt:Vertical and Qt::Horizontal (the default).
*/
void KDGanttMinimizeSplitter::setOrientation( Orientation o )
{
#if QT_VERSION >= 232
if ( orient == o )
return;
orient = o;
if ( orient == Horizontal )
setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
else
setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
QSplitterLayoutStruct *s = data->list.first();
while ( s ) {
if ( s->isSplitter )
((KDGanttSplitterHandle*)s->wid)->setOrientation( o );
s = data->list.next(); // ### next at end of loop, no iterator
}
recalc( isVisible() );
#endif
}
#if QT_VERSION >= 232
/*!
\reimp
*/
void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * )
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index f05b91b..80a83e0 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -1,96 +1,111 @@
#include <stdlib.h>
#include <stdio.h>
#include "kapplication.h"
#include "ktextedit.h"
#include <qapplication.h>
#include <qstring.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qdialog.h>
#include <qlayout.h>
#include <qtextbrowser.h>
int KApplication::random()
{
return rand();
}
//US
QString KApplication::randomString(int length)
{
if (length <=0 ) return QString::null;
QString str;
while (length--)
{
int r=random() % 62;
r+=48;
if (r>57) r+=7;
if (r>90) r+=6;
str += char(r);
// so what if I work backwards?
}
return str;
}
int KApplication::execDialog( QDialog* d )
{
if (QApplication::desktop()->width() <= 640 )
d->showMaximized();
else
;//d->resize( 800, 600 );
return d->exec();
}
void KApplication::showLicence()
{
KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" );
}
+void KApplication::testCoords( int* x, int* y, int* wid, int * hei )
+{
+ int dWid = QApplication::desktop()->width() ;
+ int dHei = QApplication::desktop()->height();
+ if ( *x + *wid > dWid ) {
+ *x = 0;
+ if ( *wid > dWid )
+ *wid = dWid;
+ }
+ if ( *y + *hei > dHei ) {
+ *y = 0;
+ if ( *hei > dHei )
+ *hei = dHei;
+ }
+}
void KApplication::showFile(QString caption, QString fn)
{
QString text;
QString fileName;
#ifndef DESKTOP_VERSION
fileName = getenv("QPEDIR");
fileName += "/pics/" + fn ;
#else
fileName = qApp->applicationDirPath () + "/" + fn;
#endif
QFile file( fileName );
if (!file.open( IO_ReadOnly ) ) {
return ;
}
QTextStream ts( &file );
text = ts.read();
file.close();
KApplication::showText( caption, text );
}
bool KApplication::convert2latin1(QString fileName)
{
QString text;
QFile file( fileName );
if (!file.open( IO_ReadOnly ) ) {
return false;
}
QTextStream ts( &file );
ts.setEncoding( QTextStream::UnicodeUTF8 );
text = ts.read();
file.close();
if (!file.open( IO_WriteOnly ) ) {
return false;
}
QTextStream tsIn( &file );
tsIn.setEncoding( QTextStream::Latin1 );
tsIn << text.latin1();
file.close();
return true;
}
void KApplication::showText(QString caption, QString text)
{
QDialog dia( 0, "name", true ); ;
dia.setCaption( caption );
diff --git a/microkde/kapplication.h b/microkde/kapplication.h
index 497ec2f..f7eb1ef 100644
--- a/microkde/kapplication.h
+++ b/microkde/kapplication.h
@@ -1,30 +1,31 @@
#ifndef MINIKDE_KAPPLICATION_H
#define MINIKDE_KAPPLICATION_H
#include "qstring.h"
#include <qdialog.h>
#ifdef QDialog
#undef QDialog
#endif
class KApplication
{
public:
static int random();
//US
/**
* Generates a random string. It operates in the range [A-Za-z0-9]
* @param length Generate a string of this length.
* @return the random string
*/
static QString randomString(int length);
static int execDialog( QDialog* );
static void showLicence();
+ static void testCoords( int* x, int* y, int* wid, int * hei );
static void showFile(QString caption, QString file);
static void showText(QString caption, QString text);
static bool convert2latin1(QString file);
};
#endif
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index 3d1889f..a3b7fff 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -35,109 +35,109 @@
#include "factory.h"
using namespace KRES;
QDict<Factory> *Factory::mSelves = 0;
static KStaticDeleter< QDict<Factory> > staticDeleter;
Factory *Factory::self( const QString& resourceFamily)
{
Factory *factory = 0;
if ( !mSelves )
{
mSelves = staticDeleter.setObject( new QDict<Factory> );
}
factory = mSelves->find( resourceFamily );
if ( !factory ) {
factory = new Factory( resourceFamily);
mSelves->insert( resourceFamily, factory );
}
return factory;
}
Factory::Factory( const QString& resourceFamily) :
mResourceFamily( resourceFamily )
{
//US so far we have three types available for resourceFamily "contact"
// and that are "file", "dir", "ldap"
/*US
KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
.arg( resourceFamily ) );
KTrader::OfferList::ConstIterator it;
for ( it = plugins.begin(); it != plugins.end(); ++it ) {
QVariant type = (*it)->property( "X-KDE-ResourceType" );
if ( !type.toString().isEmpty() )
mTypeMap.insert( type.toString(), *it );
}
*/
//US new
PluginInfo* info = new PluginInfo;
info->library = "microkabc_file";
info->nameLabel = i18n( "file" );
- info->descriptionLabel = i18n( "Choose one file" );
+ info->descriptionLabel = i18n( "One file" );
mTypeMap.insert( "file", info );
info = new PluginInfo;
info->library = "microkabc_dir";
info->nameLabel = i18n( "dir" );
- info->descriptionLabel = i18n( "Choose a directory with may files" );
+ info->descriptionLabel = i18n( "A directory with many files" );
mTypeMap.insert( "dir", info );
info = new PluginInfo;
info->library = "microkabc_ldap";
info->nameLabel = i18n( "ldap" );
- info->descriptionLabel = i18n( "No description available" );
+ info->descriptionLabel = i18n( "Connect to a directory server" );
mTypeMap.insert( "ldap", info );
//US add opie plugin only, if the library exists.
/*US
QString libname = "microkabc_opie";
QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
if ( !path.isEmpty() )
{
info = new PluginInfo;
info->library = libname;
info->nameLabel = i18n( "opie" );
info->descriptionLabel = i18n( "Opie PIM Addressbook." );
mTypeMap.insert( "opie", info );
}
*/
//US add qtopia plugin only, if the library exists.
QString libname = "microkabc_qtopia";
QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
if ( !path.isEmpty() )
{
info = new PluginInfo;
info->library = libname;
info->nameLabel = i18n( "qtopia" );
info->descriptionLabel = i18n( "Qtopia PIM Addressbook." );
mTypeMap.insert( "qtopia", info );
}
//US add sharp plugin only, if the library exists.
libname = "microkabc_sharpdtm";
path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
if ( !path.isEmpty() )
{
info = new PluginInfo;
info->library = libname;
info->nameLabel = i18n( "sharp" );
info->descriptionLabel = i18n( "Sharp DTM Addressbook." );
mTypeMap.insert( "sharp", info );
}
}
Factory::~Factory()
{
}
QStringList Factory::typeNames() const
{