author | zautrix <zautrix> | 2004-10-09 15:58:52 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-09 15:58:52 (UTC) |
commit | b80a099d9432bdc3d4eea778b1813b82b2680ecf (patch) (side-by-side diff) | |
tree | 6327321f86070a13969b07e25b9cf84d4ad10d13 /microkde | |
parent | ed1eac5e36e675b030cb5a5aa90fb2d44eb40c73 (diff) | |
download | kdepimpi-b80a099d9432bdc3d4eea778b1813b82b2680ecf.zip kdepimpi-b80a099d9432bdc3d4eea778b1813b82b2680ecf.tar.gz kdepimpi-b80a099d9432bdc3d4eea778b1813b82b2680ecf.tar.bz2 |
removed some debug output
-rw-r--r-- | microkde/kconfig.cpp | 4 | ||||
-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 2 | ||||
-rw-r--r-- | microkde/kdeui/kactioncollection.cpp | 5 | ||||
-rw-r--r-- | microkde/kdeui/klistview.cpp | 2 |
4 files changed, 7 insertions, 6 deletions
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp index ba41f6c..5b685d3 100644 --- a/microkde/kconfig.cpp +++ b/microkde/kconfig.cpp @@ -1,547 +1,547 @@ #include <qfile.h> #include <qtextstream.h> #include <qwidget.h> #include "kdebug.h" #include "kurl.h" #include "kstandarddirs.h" #include "kconfig.h" QString KConfig::mGroup = ""; //QString KConfig::mGroup = "General"; KConfig::KConfig( const QString &fileName ) : mFileName( fileName ), mDirty( false ) { mTempGroup = ""; load(); } KConfig::~KConfig() { sync(); } // we need the temp group for plugins on windows void KConfig::setTempGroup( const QString &group ) { mTempGroup = group; if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/"; } QString KConfig::tempGroup() const { return mTempGroup; } void KConfig::setGroup( const QString &group ) { mGroup = group; if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; } //US QString KConfig::group() const { return mGroup; } //US added method QValueList<int> KConfig::readIntListEntry( const QString & key) { // qDebug("KConfig::readIntListEntry key=%s:", key.latin1()); QValueList<int> result; QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key ); if ( mit == mStringMap.end() ) { return result; } QStringList valuesAsStrings = QStringList::split(":", *mit ); bool ok = false; bool ok2 = true; int val; for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { val = (*sit).toInt(&ok); result << val; if (ok == false) { qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); ok2 = false; } } if (ok2 == false) { qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); } return result; } int KConfig::readNumEntry( const QString & key, int def ) { QString res = readEntry(key, QString::number(def ) ); bool ok = false; int result = res.toInt(&ok); if ( ok ) return result; return def; } QString KConfig::readEntry( const QString &key, const QString &def ) { QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); if ( it == mStringMap.end() ) { return def; } return *it; } QSize KConfig::readSizeEntry( const QString &key, QSize* def ) { QValueList<int> intlist = readIntListEntry(key); if (intlist.count() < 2) { if (def) return *def; else return QSize(); } QSize ret; ret.setWidth(intlist[0]); ret.setHeight(intlist[1]); return ret; } QStringList KConfig::readListEntry( const QString &key ) { QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); if ( it == mStringMap.end() ) { return QStringList(); } return QStringList::split(":", *it ); } bool KConfig::readBoolEntry( const QString &key, bool def ) { QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); if ( it == mBoolMap.end() ) { return def; } return *it; } QColor KConfig::readColorEntry( const QString & e, QColor *def ) { QStringList l; l = readListEntry( e ); if (l.count() != 3 ) { if ( def ) return *def; else return QColor(); } QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); return c; } QFont KConfig::readFontEntry( const QString & e, QFont *def ) { QStringList font = readListEntry( e ); if ( font.isEmpty() ) return *def; QFont f; f.setFamily( font[0]); f.setBold ( font[1] == "bold"); f.setPointSize ( font[2].toInt()); f.setItalic( font[3] == "italic" ); return f; } QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) { QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); if ( it == mDateTimeMap.end() ) { if ( def ) return *def; else return QDateTime(); } return *it; } //US added method void KConfig::writeEntry( const QString &key, const QValueList<int> &value) { QStringList valuesAsStrings; QValueList<int>::ConstIterator it; for( it = value.begin(); it != value.end(); ++it ) { valuesAsStrings << QString::number(*it); } mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); mDirty = true; } void KConfig::writeEntry( const QString & key , int num ) { writeEntry( key, QString::number ( num ) ); } void KConfig::writeEntry( const QString &key, const QString &value ) { mStringMap.insert( mGroup + key, value ); mDirty = true; } void KConfig::writeEntry( const QString &key, const QStringList &value ) { mStringMap.insert( mGroup + key, value.join(":") ); mDirty = true; } void KConfig::writeEntry( const QString &key, bool value) { mBoolMap.insert( mGroup + key, value ); mDirty = true; } void KConfig::writeEntry( const QString & e, const QColor & c ) { QStringList l; l.append( QString::number ( c.red() ) ); l.append( QString::number ( c.green() ) ); l.append( QString::number ( c.blue() ) ); writeEntry( e, l ); } void KConfig::writeEntry( const QString & e, const QSize & s ) { QValueList<int> intlist; intlist << s.width() << s.height(); writeEntry( e, intlist ); } void KConfig::writeEntry( const QString & e , const QFont & f ) { QStringList font; font.append( f.family()); font.append( (!f.bold ()?"nonbold":"bold") ); font.append( QString::number ( f.pointSize () ) ); font.append( !f.italic ()?"nonitalic":"italic" ); writeEntry( e, font ); } void KConfig::writeEntry( const QString &key, const QDateTime &dt ) { mDateTimeMap.insert( mGroup + key, dt ); } void KConfig::load() { QFile f( mFileName ); if ( !f.open( IO_ReadOnly ) ) { - qDebug("KConfig: could not open file %s ",mFileName.latin1() ); - return; + //qDebug("KConfig: could not open file %s ",mFileName.latin1() ); + return; } mBoolMap.clear(); mStringMap.clear(); QTextStream t( &f ); QString line = t.readLine(); while ( !line.isNull() ) { QStringList tokens = QStringList::split( ",", line ); if ( tokens[0] == "bool" ) { bool value = false; if ( tokens[2] == "1" ) value = true; mBoolMap.insert( tokens[1], value ); } else if ( tokens[0] == "QString" ) { QString value = tokens[2]; mStringMap.insert( tokens[1], value ); } else if ( tokens[0] == "QDateTime" ) { #if 0 int year = tokens[2].toInt(); QDateTime dt( QDate( year, tokens[3].toInt(), tokens[4].toInt() ), QTime( tokens[5].toInt(), tokens[6].toInt(), tokens[7].toInt() ) ); mDateTimeMap.insert( tokens[1], dt ); #endif } line = t.readLine(); } } void KConfig::sync() { if ( !mDirty ) return; //qDebug("KConfig::sync() %s ",mFileName.latin1() ); //kdDebug() << "KConfig::sync(): " << mFileName << endl; //US I took the following code from a newer version of KDE // Create the containing dir if needed KURL path; path.setPath(mFileName); QString dir=path.directory(); KStandardDirs::makeDir(dir); QFile f( mFileName ); if ( !f.open( IO_WriteOnly ) ) { qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() ); return; } QTextStream t( &f ); QMap<QString,bool>::ConstIterator itBool; for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl; } QMap<QString,QString>::ConstIterator itString; for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { t << "QString," << itString.key() << "," << (*itString ) << endl; } QMap<QString,QDateTime>::ConstIterator itDateTime; for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { QDateTime dt = *itDateTime; t << "QDateTime," << itDateTime.key() << "," << dt.date().year() << "," << dt.date().month() << "," << dt.date().day() << "," << dt.time().hour() << "," << dt.time().minute() << "," << dt.time().second() << endl; } f.close(); mDirty = false; } //US I took the following deleteGroup method from a newer version from KDE. /** * Deletes a configuration entry group * * If the group is not empty and bDeep is false, nothing gets * deleted and false is returned. * If this group is the current group and it is deleted, the * current group is undefined and should be set with setGroup() * before the next operation on the configuration object. * * @param group The name of the group * returns true if we deleted at least one entry. */ bool KConfig::deleteGroup( const QString& group) { bool dirty = false; int pos; QMap<QString,bool>::Iterator itBool = mBoolMap.begin(); QMap<QString,bool>::Iterator delBool; while ( itBool != mBoolMap.end() ) { pos = itBool.key().find( group ); if (pos == 0) { delBool = itBool; ++itBool; mBoolMap.remove(delBool); dirty = true; } else ++itBool; } /* for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { pos = itBool.key().find( group ); if (pos == 0) { mBoolMap.remove(itBool); dirty = true; } } */ QMap<QString,QString>::Iterator itString = mStringMap.begin(); QMap<QString,QString>::Iterator delString ; while( itString != mStringMap.end() ) { pos = itString.key().find( group ); if (pos == 0) { delString = itString; ++itString; mStringMap.remove(delString); //qDebug("delte++++++++++++++++++ "); dirty = true; } else ++itString; } /* this leads to a memory access violation for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { pos = itString.key().find( group ); if (pos == 0) { mStringMap.remove(itString); dirty = true; } } */ QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin(); QMap<QString,QDateTime>::Iterator delDateTime; while ( itDateTime != mDateTimeMap.end() ) { pos = itDateTime.key().find( group ); if (pos == 0) { delDateTime = itDateTime; ++itDateTime; mDateTimeMap.remove(delDateTime); dirty = true; } else ++itDateTime; } /* for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { pos = itDateTime.key().find( group ); if (pos == 0) { mDateTimeMap.remove(itDateTime); dirty = true; } } */ if (dirty) mDirty = true; return dirty; } //US I took the following hasGroup method from a newer version from KDE. /** * Returns true if the specified group is known about. * * @param group The group to search for. * @return Whether the group exists. */ bool KConfig::hasGroup(const QString &group) const { QMap<QString,bool>::ConstIterator itBool; for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { if (itBool.key().find( group ) == 0) { return true; } } QMap<QString,QString>::ConstIterator itString; for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { if (itString.key().find( group ) == 0) { return true; } } QMap<QString,QDateTime>::ConstIterator itDateTime; for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { if (itDateTime.key().find( group ) == 0) { return true; } } return false; } void KConfig::deleteEntry( const QString &key) { bool dirty = false; QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); if ( itBool != mBoolMap.end() ) { mBoolMap.remove(itBool); dirty = true; } QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); if ( itString != mStringMap.end() ) { mStringMap.remove(itString); dirty = true; } QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); if ( itDateTime != mDateTimeMap.end() ) { mDateTimeMap.remove(itDateTime); dirty = true; } if (dirty) mDirty = true; } //US QString KConfig::getFileName() { return mFileName; } bool KConfig::hasKey( const QString &key) { QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); if ( itBool != mBoolMap.end() ) { return true; } QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); if ( itString != mStringMap.end() ) { return true; } QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); if ( itDateTime != mDateTimeMap.end() ) { return true; } return false; } diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index 1c3e0ae..4c03c15 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp @@ -1175,488 +1175,488 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode) if (stat(baseEncoded, &st) != 0) { // Directory does not exist.... // Or maybe a dangling symlink ? if (lstat(baseEncoded, &st) == 0) (void)unlink(baseEncoded); // try removing if ( mkdir(baseEncoded, (mode_t) mode) != 0) { perror("trying to create local folder"); return false; // Couldn't create it :-( } } */ if (dirObj.exists(base) == false) { //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); if (dirObj.mkdir(base) != true) { qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); return false; } } i = pos + 1; } return true; } static QString readEnvPath(const char *env) { //#ifdef _WIN32_ // return ""; //#else QCString c_path; if ( getenv(env) != NULL ) c_path = QString ( getenv(env) ); if (c_path.isEmpty()) return QString::null; return QFile::decodeName(c_path); //#endif } void KStandardDirs::addKDEDefaults() { //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); //return; QStringList kdedirList; // begin KDEDIRS QString kdedirs = readEnvPath("MICROKDEDIRS"); if (!kdedirs.isEmpty()) { tokenize(kdedirList, kdedirs, ":"); } else { QString kdedir = readEnvPath("MICROKDEDIR"); if (!kdedir.isEmpty()) { kdedir = KShell::tildeExpand(kdedir); kdedirList.append(kdedir); } } //US kdedirList.append(KDEDIR); //US for embedded, add qtopia dir as kdedir #ifndef DESKTOP_VERSION QString tmp = readEnvPath("QPEDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); tmp = readEnvPath("QTDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); tmp = readEnvPath("OPIEDIR"); if (!tmp.isEmpty()) kdedirList.append(tmp); #endif #ifdef __KDE_EXECPREFIX QString execPrefix(__KDE_EXECPREFIX); if (execPrefix!="NONE") kdedirList.append(execPrefix); #endif QString localKdeDir; //US if (getuid()) if (true) { localKdeDir = readEnvPath("MICROKDEHOME"); if (!localKdeDir.isEmpty()) { #ifdef _WIN32_ if (localKdeDir.at(localKdeDir.length()-1) != '\\') localKdeDir += '\\'; #else if (localKdeDir.at(localKdeDir.length()-1) != '/') localKdeDir += '/'; #endif //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); } else { localKdeDir = QDir::homeDirPath() + "/kdepim/"; } } else { // We treat root different to prevent root messing up the // file permissions in the users home directory. localKdeDir = readEnvPath("MICROKDEROOTHOME"); if (!localKdeDir.isEmpty()) { if (localKdeDir.at(localKdeDir.length()-1) != '/') localKdeDir += '/'; } else { //US struct passwd *pw = getpwuid(0); //US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); } } //US localKdeDir = appDir(); //US // qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); if (localKdeDir != "-/") { localKdeDir = KShell::tildeExpand(localKdeDir); addPrefix(localKdeDir); } for (QStringList::ConstIterator it = kdedirList.begin(); it != kdedirList.end(); it++) { QString dir = KShell::tildeExpand(*it); addPrefix(dir); } // end KDEDIRS // begin XDG_CONFIG_XXX QStringList xdgdirList; QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); if (!xdgdirs.isEmpty()) { tokenize(xdgdirList, xdgdirs, ":"); } else { xdgdirList.clear(); xdgdirList.append("/etc/xdg"); } QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); if (!localXdgDir.isEmpty()) { if (localXdgDir.at(localXdgDir.length()-1) != '/') localXdgDir += '/'; } else { //US if (getuid()) if (true) { localXdgDir = QDir::homeDirPath() + "/.config/"; } else { //US struct passwd *pw = getpwuid(0); //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); } } localXdgDir = KShell::tildeExpand(localXdgDir); addXdgConfigPrefix(localXdgDir); for (QStringList::ConstIterator it = xdgdirList.begin(); it != xdgdirList.end(); it++) { QString dir = KShell::tildeExpand(*it); addXdgConfigPrefix(dir); } // end XDG_CONFIG_XXX // begin XDG_DATA_XXX xdgdirs = readEnvPath("XDG_DATA_DIRS"); if (!xdgdirs.isEmpty()) { tokenize(xdgdirList, xdgdirs, ":"); } else { xdgdirList.clear(); for (QStringList::ConstIterator it = kdedirList.begin(); it != kdedirList.end(); it++) { QString dir = *it; if (dir.at(dir.length()-1) != '/') dir += '/'; xdgdirList.append(dir+"share/"); } xdgdirList.append("/usr/local/share/"); xdgdirList.append("/usr/share/"); } localXdgDir = readEnvPath("XDG_DATA_HOME"); if (!localXdgDir.isEmpty()) { if (localXdgDir.at(localXdgDir.length()-1) != '/') localXdgDir += '/'; } else { //US if (getuid()) if (true) { localXdgDir = QDir::homeDirPath() + "/.local/share/"; } else { //US struct passwd *pw = getpwuid(0); //US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); } } localXdgDir = KShell::tildeExpand(localXdgDir); addXdgDataPrefix(localXdgDir); for (QStringList::ConstIterator it = xdgdirList.begin(); it != xdgdirList.end(); it++) { QString dir = KShell::tildeExpand(*it); addXdgDataPrefix(dir); } // end XDG_DATA_XXX uint index = 0; while (types[index] != 0) { addResourceType(types[index], kde_default(types[index])); index++; } addResourceDir("home", QDir::homeDirPath()); } void KStandardDirs::checkConfig() const { /*US if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); */ if (!addedCustoms && KGlobal::config()) const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); } bool KStandardDirs::addCustomized(KConfig *config) { if (addedCustoms) // there are already customized entries return false; // we just quite and hope they are the right ones // save the numbers of config directories. If this changes, // we will return true to give KConfig a chance to reparse uint configdirs = resourceDirs("config").count(); // reading the prefixes in QString oldGroup = config->group(); config->setGroup("Directories"); QStringList list; QStringList::ConstIterator it; list = config->readListEntry("prefixes"); for (it = list.begin(); it != list.end(); it++) addPrefix(*it); // iterating over all entries in the group Directories // to find entries that start with dir_$type /*US QMap<QString, QString> entries = config->entryMap("Directories"); QMap<QString, QString>::ConstIterator it2; for (it2 = entries.begin(); it2 != entries.end(); it2++) { QString key = it2.key(); if (key.left(4) == "dir_") { // generate directory list, there may be more than 1. QStringList dirs = QStringList::split(',', *it2); QStringList::Iterator sIt(dirs.begin()); QString resType = key.mid(4, key.length()); for (; sIt != dirs.end(); ++sIt) { addResourceDir(resType.latin1(), *sIt); } } } // Process KIOSK restrictions. config->setGroup("KDE Resource Restrictions"); entries = config->entryMap("KDE Resource Restrictions"); for (it2 = entries.begin(); it2 != entries.end(); it2++) { QString key = it2.key(); if (!config->readBoolEntry(key, true)) { d->restrictionsActive = true; d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do dircache.remove(key.latin1()); } } */ // save it for future calls - that will return addedCustoms = true; config->setGroup(oldGroup); // return true if the number of config dirs changed return (resourceDirs("config").count() != configdirs); } QString KStandardDirs::localkdedir() const { // Return the prefix to use for saving return prefixes.first(); } QString KStandardDirs::localxdgdatadir() const { // Return the prefix to use for saving return d->xdgdata_prefixes.first(); } QString KStandardDirs::localxdgconfdir() const { // Return the prefix to use for saving return d->xdgconf_prefixes.first(); } void KStandardDirs::setAppDir( const QString &appDir ) { mAppDir = appDir; if ( mAppDir.right( 1 ) != "/" ) mAppDir += "/"; } QString KStandardDirs::appDir() { return mAppDir; } // just to make code more readable without macros QString locate( const char *type, const QString& filename/*US , const KInstance* inst*/ ) { //US return inst->dirs()->findResource(type, filename); return KGlobal::dirs()->findResource(type, filename); } QString locateLocal( const char *type, const QString& filename/*US , const KInstance* inst*/ ) { QString path = locateLocal(type, filename, true /*US, inst*/); /* static int ccc = 0; ++ccc; if ( ccc > 13 ) abort(); */ - qDebug("locatelocal: %s" , path.latin1()); + //qDebug("locatelocal: %s" , path.latin1()); return path; /*US why do we put all files into one directory. It is quit complicated. why not staying with the original directorystructure ? QString escapedFilename = filename; escapedFilename.replace( QRegExp( "/" ), "_" ); QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; kdDebug() << "locate: '" << path << "'" << endl; qDebug("locate: %s" , path.latin1()); return path; */ //US so my proposal is this: // QString escapedFilename = filename; // escapedFilename.replace( QRegExp( "/" ), "_" ); #if 0 #ifdef _WIN32_ QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); #else QString path = KStandardDirs::appDir() + type + "/" + filename; #endif //US Create the containing dir if needed QFileInfo fi ( path ); // QString dir=pathurl.directory(); // QMessageBox::information( 0,"path", path, 1 ); #ifdef _WIN32_ KStandardDirs::makeDir(path); #else KStandardDirs::makeDir(fi.dirPath( true )); #endif qDebug("locate22: %s" , path.latin1()); return path; #endif } QString locateLocal( const char *type, const QString& filename, bool createDir/*US , const KInstance* inst*/ ) { // try to find slashes. If there are some, we have to // create the subdir first int slash = filename.findRev('/')+1; if (!slash) // only one filename //US return inst->dirs()->saveLocation(type, QString::null, createDir) + filename; return KGlobal::dirs()->saveLocation(type, QString::null, createDir) + filename; // split path from filename QString dir = filename.left(slash); QString file = filename.mid(slash); //US return inst->dirs()->saveLocation(type, dir, createDir) + file; return KGlobal::dirs()->saveLocation(type, dir, createDir) + file; // *************************************************************** #if 0 /*US why do we put all files into one directory. It is quit complicated. why not staying with the original directorystructure ? QString escapedFilename = filename; escapedFilename.replace( QRegExp( "/" ), "_" ); QString path = KStandardDirs::appDir() + type + "_" + escapedFilename; kdDebug() << "locate: '" << path << "'" << endl; qDebug("locate: %s" , path.latin1()); return path; */ //US so my proposal is this: // QString escapedFilename = filename; // escapedFilename.replace( QRegExp( "/" ), "_" ); #ifdef _WIN32_ QString path = QDir::convertSeparators(KStandardDirs::appDir() + type + "/" + filename); #else QString path = KStandardDirs::appDir() + type + "/" + filename; #endif //US Create the containing dir if needed KURL pathurl; pathurl.setPath(path); QString dir=pathurl.directory(); // QMessageBox::information( 0,"path", path, 1 ); #ifdef _WIN32_ KStandardDirs::makeDir(path); #else KStandardDirs::makeDir(dir); #endif return path; #endif } diff --git a/microkde/kdeui/kactioncollection.cpp b/microkde/kdeui/kactioncollection.cpp index b819e76..69e5d02 100644 --- a/microkde/kdeui/kactioncollection.cpp +++ b/microkde/kdeui/kactioncollection.cpp @@ -1,544 +1,545 @@ /* This file is part of the KDE libraries Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> (C) 1999 Simon Hausmann <hausmann@kde.org> (C) 2000 Nicolas Hadacek <haadcek@kde.org> (C) 2000 Kurt Granroth <granroth@kde.org> (C) 2000 Michael Koch <koch@kde.org> (C) 2001 Holger Freyther <freyther@kde.org> (C) 2002 Ellis Whitehead <ellis@kde.org> (C) 2002 Joseph Wenninger <jowenn@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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. */ #include "kactioncollection.h" //US#include "kactionshortcutlist.h" #include <qptrdict.h> //US#include <qvariant.h> //US#include <kaccel.h> //US#include <kaccelbase.h> //US#include <kapplication.h> #include <kdebug.h> //US#include <kxmlguifactory.h> //US I included the following files #include <qasciidict.h> #include <qptrlist.h> #include "kaction.h" #include <kglobal.h> #include <qobject.h> #include <qwidget.h> class KActionCollection::KActionCollectionPrivate { public: KActionCollectionPrivate() { //US m_instance = 0; //m_bOneKAccelOnly = false; //m_iWidgetCurrent = 0; m_bAutoConnectShortcuts = true; m_widget = 0; m_kaccel = m_builderKAccel = 0; m_dctHighlightContainers.setAutoDelete( true ); m_highlight = false; m_currentHighlightAction = 0; m_statusCleared = true; } //US KInstance *m_instance; //US QString m_sXMLFile; bool m_bAutoConnectShortcuts; //bool m_bOneKAccelOnly; //int m_iWidgetCurrent; //QValueList<QWidget*> m_widgetList; //QValueList<KAccel*> m_kaccelList; QValueList<KActionCollection*> m_docList; QWidget *m_widget; KAccel *m_kaccel; KAccel *m_builderKAccel; QAsciiDict<KAction> m_actionDict; QPtrDict< QPtrList<KAction> > m_dctHighlightContainers; bool m_highlight; KAction *m_currentHighlightAction; bool m_statusCleared; }; KActionCollection::KActionCollection( QWidget *parent, const char *name /*US, KInstance *instance */) : QObject( (QObject*)parent, name ) { kdDebug(129) << "KActionCollection::KActionCollection( " << parent << ", " << name << " ): this = " << this << endl; // ellis d = new KActionCollectionPrivate; if( parent ) setWidget( parent ); //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); //US setInstance( instance ); } KActionCollection::KActionCollection( QWidget *watch, QObject* parent, const char *name /*US, KInstance *instance */) : QObject( parent, name ) { kdDebug(129) << "KActionCollection::KActionCollection( " << watch << ", " << parent << ", " << name << " ): this = " << this << endl; //ellis d = new KActionCollectionPrivate; if( watch ) setWidget( watch ); //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); //US setInstance( instance ); } // KDE 4: remove KActionCollection::KActionCollection( QObject *parent, const char *name /*US, KInstance *instance */) : QObject( parent, name ) { kdWarning(129) << "KActionCollection::KActionCollection( QObject *parent, const char *name, KInstance *instance )" << endl; //ellis //US kdBacktrace not available //US kdDebug(129) << kdBacktrace() << endl; d = new KActionCollectionPrivate; //US QWidget* w = dynamic_cast<QWidget*>( parent ); QWidget* w = (QWidget*)( parent ); if( w ) setWidget( w ); //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); //US setInstance( instance ); } KActionCollection::KActionCollection( const KActionCollection © ) : QObject() { kdWarning(129) << "KActionCollection::KActionCollection( const KActionCollection & ): function is severely deprecated." << endl; d = new KActionCollectionPrivate; *this = copy; } // KDE 4: remove end KActionCollection::~KActionCollection() { kdDebug(129) << "KActionCollection::~KActionCollection(): this = " << this << endl; for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { KAction* pAction = it.current(); if ( pAction->m_parentCollection == this ) pAction->m_parentCollection = 0L; } //US delete d->m_kaccel; //US delete d->m_builderKAccel; delete d; d = 0; } void KActionCollection::setWidget( QWidget* w ) { //if ( d->m_actionDict.count() > 0 ) { // kdError(129) << "KActionCollection::setWidget(): must be called before any actions are added to collection!" << endl; // kdDebug(129) << kdBacktrace() << endl; //} //else if ( !d->m_widget ) { d->m_widget = w; - qDebug("KActionCollection::setWidget: warning: KAccel is never used in microkde"); + //qDebug("KActionCollection::setWidget: warning: KAccel is never used in microkde"); //US d->m_kaccel = new KAccel( w, this, "KActionCollection-KAccel" ); } else if ( d->m_widget != w ) - kdWarning(129) << "KActionCollection::setWidget(): tried to change widget from " << d->m_widget << " to " << w << endl; + ; + } void KActionCollection::setAutoConnectShortcuts( bool b ) { d->m_bAutoConnectShortcuts = b; } bool KActionCollection::isAutoConnectShortcuts() { return d->m_bAutoConnectShortcuts; } bool KActionCollection::addDocCollection( KActionCollection* pDoc ) { d->m_docList.append( pDoc ); return true; } void KActionCollection::beginXMLPlug( QWidget *widget ) { qDebug("KActionCollection::beginXMLPlug has to be fixed"); /*US kdDebug(129) << "KActionCollection::beginXMLPlug( buildWidget = " << widget << " ): this = " << this << " d->m_builderKAccel = " << d->m_builderKAccel << endl; if( widget && !d->m_builderKAccel ) { d->m_builderKAccel = new KAccel( widget, this, "KActionCollection-BuilderKAccel" ); } */ } void KActionCollection::endXMLPlug() { kdDebug(129) << "KActionCollection::endXMLPlug(): this = " << this << endl; //s_kaccelXML = 0; } void KActionCollection::prepareXMLUnplug() { qDebug("KActionCollection::prepareXMLUnplug has to be fixed"); /*US kdDebug(129) << "KActionCollection::prepareXMLUnplug(): this = " << this << endl; unplugShortcuts( d->m_kaccel ); if( d->m_builderKAccel ) { unplugShortcuts( d->m_builderKAccel ); delete d->m_builderKAccel; d->m_builderKAccel = 0; } */ } void KActionCollection::unplugShortcuts( KAccel* kaccel ) { qDebug("KActionCollection::unplugShortcuts has to be fixed"); /*US for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { KAction* pAction = it.current(); pAction->removeKAccel( kaccel ); } for( uint i = 0; i < d->m_docList.count(); i++ ) d->m_docList[i]->unplugShortcuts( kaccel ); */ } /*void KActionCollection::addWidget( QWidget* w ) { if( !d->m_bOneKAccelOnly ) { kdDebug(129) << "KActionCollection::addWidget( " << w << " ): this = " << this << endl; for( uint i = 0; i < d->m_widgetList.count(); i++ ) { if( d->m_widgetList[i] == w ) { d->m_iWidgetCurrent = i; return; } } d->m_iWidgetCurrent = d->m_widgetList.count(); d->m_widgetList.append( w ); d->m_kaccelList.append( new KAccel( w, this, "KActionCollection-KAccel" ) ); } } void KActionCollection::removeWidget( QWidget* w ) { if( !d->m_bOneKAccelOnly ) { kdDebug(129) << "KActionCollection::removeWidget( " << w << " ): this = " << this << endl; for( uint i = 0; i < d->m_widgetList.count(); i++ ) { if( d->m_widgetList[i] == w ) { // Remove KAccel object from children. KAccel* pKAccel = d->m_kaccelList[i]; for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { KAction* pAction = it.current(); if ( pAction->m_parentCollection == this ) { pAction->removeKAccel( pKAccel ); } } delete pKAccel; d->m_widgetList.remove( d->m_widgetList.at( i ) ); d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); if( d->m_iWidgetCurrent == (int)i ) d->m_iWidgetCurrent = -1; else if( d->m_iWidgetCurrent > (int)i ) d->m_iWidgetCurrent--; return; } } kdWarning(129) << "KActionCollection::removeWidget( " << w << " ): widget not in list." << endl; } } bool KActionCollection::ownsKAccel() const { return d->m_bOneKAccelOnly; } uint KActionCollection::widgetCount() const { return d->m_widgetList.count(); } const KAccel* KActionCollection::widgetKAccel( uint i ) const { return d->m_kaccelList[i]; }*/ //US we are using no accelerators so far. So just setup an empty implementation. KAccel* KActionCollection::kaccel() { //if( d->m_kaccelList.count() > 0 ) // return d->m_kaccelList[d->m_iWidgetCurrent]; //else // return 0; //US return d->m_kaccel; return 0; } //US we are using no accelerators so far. So just setup an empty implementation. const KAccel* KActionCollection::kaccel() const { //if( d->m_kaccelList.count() > 0 ) // return d->m_kaccelList[d->m_iWidgetCurrent]; //else // return 0; //USreturn d->m_kaccel; return 0; } /*void KActionCollection::findMainWindow( QWidget *w ) { // Note: topLevelWidget() stops too early, we can't use it. QWidget * tl = w; while ( tl->parentWidget() ) // lookup parent and store tl = tl->parentWidget(); KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow if (mw) d->m_mainwindow = mw; else kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; }*/ void KActionCollection::_insert( KAction* action ) { char unnamed_name[100]; const char *name = action->name(); if( qstrcmp( name, "unnamed" ) == 0 ) { sprintf(unnamed_name, "unnamed-%p", (void *)action); name = unnamed_name; } KAction *a = d->m_actionDict[ name ]; if ( a == action ) return; d->m_actionDict.insert( name, action ); emit inserted( action ); } void KActionCollection::_remove( KAction* action ) { delete _take( action ); } KAction* KActionCollection::_take( KAction* action ) { char unnamed_name[100]; const char *name = action->name(); if( qstrcmp( name, "unnamed" ) == 0 ) { sprintf(unnamed_name, "unnamed-%p", (void *) action); name = unnamed_name; } KAction *a = d->m_actionDict.take( name ); if ( !a || a != action ) return 0; emit removed( action ); return a; } void KActionCollection::_clear() { QAsciiDictIterator<KAction> it( d->m_actionDict ); while ( it.current() ) _remove( it.current() ); } void KActionCollection::insert( KAction* action ) { _insert( action ); } void KActionCollection::remove( KAction* action ) { _remove( action ); } KAction* KActionCollection::take( KAction* action ) { return _take( action ); } void KActionCollection::clear() { _clear(); } KAccel* KActionCollection::accel() { return kaccel(); } const KAccel* KActionCollection::accel() const { return kaccel(); } KAccel* KActionCollection::builderKAccel() const { return d->m_builderKAccel; } KAction* KActionCollection::action( const char* name, const char* classname ) const { KAction* pAction = 0; if ( !classname && name ) pAction = d->m_actionDict[ name ]; else { QAsciiDictIterator<KAction> it( d->m_actionDict ); for( ; it.current(); ++it ) { if ( ( !name || strcmp( it.current()->name(), name ) == 0 ) && ( !classname || strcmp( it.current()->className(), classname ) == 0 ) ) { pAction = it.current(); break; } } } if( !pAction ) { for( uint i = 0; i < d->m_docList.count() && !pAction; i++ ) pAction = d->m_docList[i]->action( name, classname ); } return pAction; } KAction* KActionCollection::action( int index ) const { QAsciiDictIterator<KAction> it( d->m_actionDict ); it += index; return it.current(); // return d->m_actions.at( index ); } /*US bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) { return KActionShortcutList(this).readSettings( sConfigGroup, pConfig ); } bool KActionCollection::writeShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) const { return KActionShortcutList((KActionCollection*)this).writeSettings( sConfigGroup, pConfig ); } */ uint KActionCollection::count() const { return d->m_actionDict.count(); } QStringList KActionCollection::groups() const { QStringList lst; QAsciiDictIterator<KAction> it( d->m_actionDict ); for( ; it.current(); ++it ) if ( !it.current()->group().isEmpty() && !lst.contains( it.current()->group() ) ) lst.append( it.current()->group() ); return lst; } KActionPtrList KActionCollection::actions( const QString& group ) const { KActionPtrList lst; QAsciiDictIterator<KAction> it( d->m_actionDict ); for( ; it.current(); ++it ) if ( it.current()->group() == group ) lst.append( it.current() ); else if ( it.current()->group().isEmpty() && group.isEmpty() ) lst.append( it.current() ); return lst; } KActionPtrList KActionCollection::actions() const { KActionPtrList lst; QAsciiDictIterator<KAction> it( d->m_actionDict ); for( ; it.current(); ++it ) lst.append( it.current() ); return lst; } /*US we have no instance object. Use KGlobal instead void KActionCollection::setInstance( KInstance *instance ) { if ( instance ) d->m_instance = instance; qDebug("KActionCollection::setInstance has to be fixed"); else d->m_instance = KGlobal::instance(); } KInstance *KActionCollection::instance() const { return d->m_instance; } */ /*US we have no XML facility in microkde void KActionCollection::setXMLFile( const QString& sXMLFile ) { d->m_sXMLFile = sXMLFile; } const QString& KActionCollection::xmlFile() const { return d->m_sXMLFile; } */ void KActionCollection::setHighlightingEnabled( bool enable ) { d->m_highlight = enable; } bool KActionCollection::highlightingEnabled() const { return d->m_highlight; } void KActionCollection::connectHighlight( QWidget *container, KAction *action ) { if ( !d->m_highlight ) return; QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; if ( !actionList ) { actionList = new QPtrList<KAction>; if ( container->inherits( "QPopupMenu" ) ) { connect( container, SIGNAL( highlighted( int ) ), this, SLOT( slotMenuItemHighlighted( int ) ) ); connect( container, SIGNAL( aboutToHide() ), this, SLOT( slotMenuAboutToHide() ) ); } //US else if ( container->inherits( "KToolBar" ) ) else if ( container->inherits( "QToolBar" ) ) { connect( container, SIGNAL( highlighted( int, bool ) ), this, SLOT( slotToolBarButtonHighlighted( int, bool ) ) ); } connect( container, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); d->m_dctHighlightContainers.insert( container, actionList ); } actionList->append( action ); } void KActionCollection::disconnectHighlight( QWidget *container, KAction *action ) { if ( !d->m_highlight ) return; QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp index b53a88a..2856f2d 100644 --- a/microkde/kdeui/klistview.cpp +++ b/microkde/kdeui/klistview.cpp @@ -134,769 +134,769 @@ public: QPoint dragOverPoint; QPoint startDragPos; int dragDelay; //US KListViewLineEdit *editor; QValueList<int> renameable; bool cursorInExecuteArea:1; bool bUseSingle:1; bool bChangeCursorOverItem:1; bool itemsMovable:1; bool selectedBySimpleMove : 1; bool selectedUsingMouse:1; bool itemsRenameable:1; bool validDrag:1; bool dragEnabled:1; bool autoOpen:1; bool dropVisualizer:1; bool dropHighlighter:1; bool createChildren:1; bool pressedOnSelected:1; bool wasShiftEvent:1; bool fullWidth:1; bool sortAscending:1; bool tabRename:1; int sortColumn; //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX int selectionDirection; int tooltipColumn; SelectionModeExt selectionMode; int contextMenuKey; bool showContextMenusOnPress; QRect mOldDropVisualizer; int mDropVisualizerWidth; QRect mOldDropHighlighter; QListViewItem *afterItemDrop; QListViewItem *parentItemDrop; QColor alternateBackground; }; /*US KListViewLineEdit::KListViewLineEdit(KListView *parent) : KLineEdit(parent->viewport()), item(0), col(0), p(parent) { setFrame( false ); hide(); connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); } KListViewLineEdit::~KListViewLineEdit() { } void KListViewLineEdit::load(QListViewItem *i, int c) { item=i; col=c; QRect rect(p->itemRect(i)); setText(item->text(c)); int fieldX = rect.x() - 1; int fieldW = p->columnWidth(col) + 2; int pos = p->header()->mapToIndex(col); for ( int index = 0; index < pos; index++ ) fieldX += p->columnWidth( p->header()->mapToSection( index )); if ( col == 0 ) { int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); d *= p->treeStepSize(); fieldX += d; fieldW -= d; } if ( i->pixmap( col ) ) {// add width of pixmap int d = i->pixmap( col )->width(); fieldX += d; fieldW -= d; } setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); show(); setFocus(); } */ /* Helper functions to for * tabOrderedRename functionality. */ static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) { if (pi) { // Find the next renameable column in the current row for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) if (pl->isRenameable(start)) return start; } return -1; } static QListViewItem *prevItem (QListViewItem *pi) { QListViewItem *pa = pi->itemAbove(); /* Does what the QListViewItem::previousSibling() * of my dreams would do. */ if (pa && pa->parent() == pi->parent()) return pa; return NULL; } static QListViewItem *lastQChild (QListViewItem *pi) { if (pi) { /* Since there's no QListViewItem::lastChild(). * This finds the last sibling for the given * item. */ for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) pi = pt; } return pi; } /*US void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) { const int ncols = p->columns(); const int dir = forward ? +1 : -1; const int restart = forward ? 0 : (ncols - 1); QListViewItem *top = (pitem && pitem->parent()) ? pitem->parent()->firstChild() : p->firstChild(); QListViewItem *pi = pitem; terminate(); // Save current changes do { */ /* Check the rest of the current row for an editable column, * if that fails, check the entire next/previous row. The * last case goes back to the first item in the current branch * or the last item in the current branch depending on the * direction. */ /*US if ((column = nextCol(p, pi, column + dir, dir)) != -1 || (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) { if (pi) { p->setCurrentItem(pi); // Calls terminate p->rename(pi, column); */ /* Some listviews may override rename() to * prevent certain items from being renamed, * if this is done, [m_]item will be NULL * after the rename() call... try again. */ /*US if (!item) continue; break; } } } while (pi && !item); } */ /*US #ifdef KeyPress #undef KeyPress #endif bool KListViewLineEdit::event (QEvent *pe) { if (pe->type() == QEvent::KeyPress) { QKeyEvent *k = (QKeyEvent *) pe; if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && p->tabOrderedRenaming() && p->itemsRenameable() && !(k->state() & ControlButton || k->state() & AltButton)) { selectNextCell(item, col, (k->key() == Key_Tab && !(k->state() & ShiftButton))); return true; } } return KLineEdit::event(pe); } void KListViewLineEdit::keyPressEvent(QKeyEvent *e) { if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) terminate(true); else if(e->key() == Qt::Key_Escape) terminate(false); else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) { terminate(true); KLineEdit::keyPressEvent(e); } else KLineEdit::keyPressEvent(e); } void KListViewLineEdit::terminate() { terminate(true); } void KListViewLineEdit::terminate(bool commit) { if ( item ) { //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; if (commit) item->setText(col, text()); int c=col; QListViewItem *i=item; col=0; item=0; hide(); // will call focusOutEvent, that's why we set item=0 before emit done(i,c); } } void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) { QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); // Don't let a RMB close the editor if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) terminate(true); } void KListViewLineEdit::paintEvent( QPaintEvent *e ) { KLineEdit::paintEvent( e ); if ( !frame() ) { QPainter p( this ); p.setClipRegion( e->region() ); p.drawRect( rect() ); } } // selection changed -> terminate. As our "item" can be already deleted, // we can't call terminate(false), because that would emit done() with // a dangling pointer to "item". void KListViewLineEdit::slotSelectionChanged() { item = 0; col = 0; hide(); } */ KListView::KListView( QWidget *parent, const char *name ) : QListView( parent, name ), d (new KListViewPrivate (this)) { #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif //US setDragAutoScroll(true); connect( this, SIGNAL( onViewport() ), this, SLOT( slotOnViewport() ) ); connect( this, SIGNAL( onItem( QListViewItem * ) ), this, SLOT( slotOnItem( QListViewItem * ) ) ); connect (this, SIGNAL(contentsMoving(int,int)), this, SLOT(cleanDropVisualizer())); connect (this, SIGNAL(contentsMoving(int,int)), this, SLOT(cleanItemHighlighter())); /*US slotSettingsChanged(KApplication::SETTINGS_MOUSE); if (kapp) { connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); kapp->addKipcEventMask( KIPC::SettingsChanged ); } */ slotSettingsChanged(1); //US do this to initialize the connections connect(&d->autoSelect, SIGNAL( timeout() ), this, SLOT( slotAutoSelect() ) ); connect(&d->dragExpand, SIGNAL( timeout() ), this, SLOT( slotDragExpand() ) ); // context menu handling if (d->showContextMenusOnPress) { connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } else { connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), this, SLOT (emitContextMenu (KListView*, QListViewItem*))); //qDebug("KListView::KListView make alternate color configurable"); //US d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); d->alternateBackground = QColor(240, 240, 240); } KListView::~KListView() { delete d; } bool KListView::isExecuteArea( const QPoint& point ) { if ( itemAt( point ) ) return isExecuteArea( point.x() ); return false; } bool KListView::isExecuteArea( int x ) { if( allColumnsShowFocus() ) return true; else { int offset = 0; int width = columnWidth( 0 ); int pos = header()->mapToIndex( 0 ); for ( int index = 0; index < pos; index++ ) offset += columnWidth( header()->mapToSection( index ) ); x += contentsX(); // in case of a horizontal scrollbar return ( x > offset && x < ( offset + width ) ); } } void KListView::slotOnItem( QListViewItem *item ) { QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { d->autoSelect.start( d->autoSelectDelay, true ); d->pCurrentItem = item; } } void KListView::slotOnViewport() { if ( d->bChangeCursorOverItem ) viewport()->unsetCursor(); d->autoSelect.stop(); d->pCurrentItem = 0L; } void KListView::slotSettingsChanged(int category) { -qDebug("KListView::slotSettingsChanged has to be verified"); + //qDebug("KListView::slotSettingsChanged has to be verified"); /*US switch (category) { case KApplication::SETTINGS_MOUSE: d->dragDelay = KGlobalSettings::dndEventDelay(); d->bUseSingle = KGlobalSettings::singleClick(); disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); if( d->bUseSingle ) connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); if( !d->bUseSingle || !d->bChangeCursorOverItem ) viewport()->unsetCursor(); break; case KApplication::SETTINGS_POPUPMENU: d->contextMenuKey = KGlobalSettings::contextMenuKey (); d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); if (d->showContextMenusOnPress) { disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } else { disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } break; default: break; } */ if( d->bUseSingle ) connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); } void KListView::slotAutoSelect() { // check that the item still exists if( itemIndex( d->pCurrentItem ) == -1 ) return; if (!isActiveWindow()) { d->autoSelect.stop(); return; } //Give this widget the keyboard focus. if( !hasFocus() ) setFocus(); QListViewItem* previousItem = currentItem(); setCurrentItem( d->pCurrentItem ); #if 0 #ifndef Q_WS_QWS // FIXME(E): Implement for Qt Embedded if( d->pCurrentItem ) { //Shift pressed? if( (keybstate & ShiftMask) ) { bool block = signalsBlocked(); blockSignals( true ); //No Ctrl? Then clear before! if( !(keybstate & ControlMask) ) clearSelection(); bool select = !d->pCurrentItem->isSelected(); bool update = viewport()->isUpdatesEnabled(); viewport()->setUpdatesEnabled( false ); bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); for ( ; lit.current(); ++lit ) { if ( down && lit.current() == d->pCurrentItem ) { d->pCurrentItem->setSelected( select ); break; } if ( !down && lit.current() == previousItem ) { previousItem->setSelected( select ); break; } lit.current()->setSelected( select ); } blockSignals( block ); viewport()->setUpdatesEnabled( update ); triggerUpdate(); emit selectionChanged(); if( selectionMode() == QListView::Single ) emit selectionChanged( d->pCurrentItem ); } else if( (keybstate & ControlMask) ) setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); else { bool block = signalsBlocked(); blockSignals( true ); if( !d->pCurrentItem->isSelected() ) clearSelection(); blockSignals( block ); setSelected( d->pCurrentItem, true ); } } else kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; #endif #endif } void KListView::slotHeaderChanged() { if (d->fullWidth && columns()) { int w = 0; for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); } } void KListView::emitExecute( QListViewItem *item, const QPoint &pos, int c ) { if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { // Double click mode ? if ( !d->bUseSingle ) { emit executed( item ); emit executed( item, pos, c ); } else { #if 0 #ifndef Q_WS_QWS // FIXME(E): Implement for Qt Embedded Window root; Window child; int root_x, root_y, win_x, win_y; uint keybstate; XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, &root_x, &root_y, &win_x, &win_y, &keybstate ); d->autoSelect.stop(); //Dont emit executed if in SC mode and Shift or Ctrl are pressed if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { emit executed( item ); emit executed( item, pos, c ); } #endif #endif } } } void KListView::focusInEvent( QFocusEvent *fe ) { // kdDebug()<<"KListView::focusInEvent()"<<endl; QListView::focusInEvent( fe ); if ((d->selectedBySimpleMove) && (d->selectionMode == FileManager) && (fe->reason()!=QFocusEvent::Popup) && (fe->reason()!=QFocusEvent::ActiveWindow) && (currentItem()!=0)) { currentItem()->setSelected(true); currentItem()->repaint(); emit selectionChanged(); }; } void KListView::focusOutEvent( QFocusEvent *fe ) { cleanDropVisualizer(); cleanItemHighlighter(); d->autoSelect.stop(); if ((d->selectedBySimpleMove) && (d->selectionMode == FileManager) && (fe->reason()!=QFocusEvent::Popup) && (fe->reason()!=QFocusEvent::ActiveWindow) && (currentItem()!=0) /*US && (!d->editor->isVisible()) */ ) { currentItem()->setSelected(false); currentItem()->repaint(); emit selectionChanged(); }; QListView::focusOutEvent( fe ); } void KListView::leaveEvent( QEvent *e ) { d->autoSelect.stop(); QListView::leaveEvent( e ); } bool KListView::event( QEvent *e ) { if (e->type() == QEvent::ApplicationPaletteChange) { qDebug("KListView::event make alternate color configurable"); //US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); d->alternateBackground = QColor(240, 240, 240); } return QListView::event(e); } void KListView::contentsMousePressEvent( QMouseEvent *e ) { if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) { bool block = signalsBlocked(); blockSignals( true ); clearSelection(); blockSignals( block ); } else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) { d->selectedBySimpleMove=false; d->selectedUsingMouse=true; if (currentItem()!=0) { currentItem()->setSelected(false); currentItem()->repaint(); // emit selectionChanged(); }; }; QPoint p( contentsToViewport( e->pos() ) ); QListViewItem *at = itemAt (p); // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) bool rootDecoClicked = at && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); if (e->button() == LeftButton && !rootDecoClicked) { //Start a drag d->startDragPos = e->pos(); if (at) { d->validDrag = true; d->pressedOnSelected = at->isSelected(); } } QListView::contentsMousePressEvent( e ); } void KListView::contentsMouseMoveEvent( QMouseEvent *e ) { if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { QListView::contentsMouseMoveEvent (e); return; } QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt( vp ); //do we process cursor changes at all? if ( item && d->bChangeCursorOverItem && d->bUseSingle ) { //Cursor moved on a new item or in/out the execute area if( (item != d->pCurrentItem) || (isExecuteArea(vp) != d->cursorInExecuteArea) ) { d->cursorInExecuteArea = isExecuteArea(vp); qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); /*US if( d->cursorInExecuteArea ) //cursor moved in execute area viewport()->setCursor( KCursor::handCursor() ); else //cursor moved out of execute area viewport()->unsetCursor(); */ } } bool dragOn = dragEnabled(); QPoint newPos = e->pos(); if (dragOn && d->validDrag && (newPos.x() > d->startDragPos.x()+d->dragDelay || newPos.x() < d->startDragPos.x()-d->dragDelay || newPos.y() > d->startDragPos.y()+d->dragDelay || newPos.y() < d->startDragPos.y()-d->dragDelay)) //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { QListView::contentsMouseReleaseEvent( 0 ); startDrag(); d->startDragPos = QPoint(); d->validDrag = false; } } void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) { if (e->button() == LeftButton) { // If the row was already selected, maybe we want to start an in-place editing if ( d->pressedOnSelected && itemsRenameable() ) { QPoint p( contentsToViewport( e->pos() ) ); QListViewItem *at = itemAt (p); if ( at ) { // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) bool rootDecoClicked = ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); if (!rootDecoClicked) { int col = header()->mapToLogical( header()->cellAt( p.x() ) ); if ( d->renameable.contains(col) ) rename(at, col); } } } d->pressedOnSelected = false; d->validDrag = false; d->startDragPos = QPoint(); } QListView::contentsMouseReleaseEvent( e ); } void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) { // We don't want to call the parent method because it does setOpen, // whereas we don't do it in single click mode... (David) //QListView::contentsMouseDoubleClickEvent( e ); QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt( vp ); emit QListView::doubleClicked( item ); // we do it now int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; if( item ) { emit doubleClicked( item, e->globalPos(), col ); if( (e->button() == LeftButton) && !d->bUseSingle ) emitExecute( item, e->globalPos(), col ); } } void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) { if( (btn == LeftButton) && item ) emitExecute(item, pos, c); } |