-rw-r--r-- | microkde/kdatetbl.cpp | 2 | ||||
-rw-r--r-- | microkde/kdecore/kstandarddirs.cpp | 4 | ||||
-rw-r--r-- | microkde/kdecore/kstandarddirs.h | 4 |
3 files changed, 8 insertions, 2 deletions
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp index d182279..2d97c8c 100644 --- a/microkde/kdatetbl.cpp +++ b/microkde/kdatetbl.cpp @@ -263,129 +263,129 @@ KDateTable::keyPressEvent( QKeyEvent *e ) if(pos+dayoff<=firstday) { // this day is in the previous month KNotifyClient::beep(); return; } if(firstday+numdays<pos+dayoff) { // this date is in the next month KNotifyClient::beep(i18n( "Month not long enough" )); return; } if ( pos == temp ) return; setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); updateCell(temp/7+1, temp%7); // Update the previously selected cell updateCell(pos/7+1, pos%7); // Update the selected cell assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); } void KDateTable::viewportResizeEvent(QResizeEvent * e) { QGridView::viewportResizeEvent(e); setCellWidth(viewport()->width()/7); setCellHeight(viewport()->height()/7); } void KDateTable::setFontSize(int size) { int count; QRect rect; // ----- store rectangles: fontsize=size; QFont _font = font(); _font.setPointSize(fontsize); setFont( _font ); _font.setBold( true ); QFontMetrics metrics(_font); // ----- find largest day name: maxCell.setWidth(0); maxCell.setHeight(0); for(count=0; count<7; ++count) { rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); maxCell.setWidth(QMAX(maxCell.width(), rect.width())); maxCell.setHeight(QMAX(maxCell.height(), rect.height())); } // ----- compare with a real wide number and add some space: rect=metrics.boundingRect(QString::fromLatin1("88")); maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); #ifdef DESKTOP_VERSION maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); #else maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); #endif if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { maxCell.setHeight(maxCell.width() * 1000 / 1900 ); - qDebug("setmax "); + //qDebug("setmax "); } } void KDateTable::contentsMousePressEvent(QMouseEvent *e) { if(e->type()!=QEvent::MouseButtonPress) { // the KDatePicker only reacts on mouse press events: return; } if(!isEnabled()) { KNotifyClient::beep(); return; } int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; // ----- int row, col, pos, temp; QPoint mouseCoord; // ----- mouseCoord = e->pos(); row=rowAt(mouseCoord.y()); col=columnAt(mouseCoord.x()); if(row<0 || col<0) { // the user clicked on the frame of the table return; } pos=7*(row-1)+col+1; #if 0 if(pos+dayoff<=firstday) { // this day is in the previous month KNotifyClient::beep(); return; } if(firstday+numdays<pos+dayoff) { // this date is in the next month KNotifyClient::beep(); return; } #endif temp=firstday+date.day()-dayoff-1; QDate da = QDate(date.year(), date.month(),1); setDate(da.addDays( pos-firstday+dayoff-1)); updateCell(temp/7+1, temp%7); // Update the previously selected cell updateCell(row, col); // Update the selected cell // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); emit(tableClicked()); } bool KDateTable::setDate(const QDate& date_) { bool changed=false; QDate temp; mMarkCurrent = false; // ----- if(!date_.isValid()) { kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; return false; } if(date!=date_) { diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp index 810c889..4ab1a68 100644 --- a/microkde/kdecore/kstandarddirs.cpp +++ b/microkde/kdecore/kstandarddirs.cpp @@ -1142,231 +1142,233 @@ bool KStandardDirs::makeDir(const QString& dir2, int mode) // we want an absolute path #ifndef _WIN32_ if (dir.at(0) != '/') return false; #endif QString target = dir; uint len = target.length(); #ifndef _WIN32_ // append trailing slash if missing if (dir.at(len - 1) != '/') target += '/'; #endif QString base(""); uint i = 1; while( i < len ) { //US struct stat st; #ifndef _WIN32_ int pos = target.find('/', i); #else int pos = target.find('\\', i); #endif if ( pos < 0 ) return true; base += target.mid(i - 1, pos - i + 1); //QMessageBox::information( 0,"cap111", base, 1 ); /*US QCString baseEncoded = QFile::encodeName(base); // bail out if we encountered a problem 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) +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 { QString confFile; #ifdef DESKTOP_VERSION confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; QFileInfo fi ( confFile ); if ( !fi.exists() ) confFile = QDir::homeDirPath() + "/.microkdehome"; else qDebug("Loading path info from " + confFile ); #else confFile = QDir::homeDirPath() + "/.microkdehome"; #endif KConfig cfg ( confFile ); cfg.setGroup("Global"); localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" ); #ifdef DESKTOP_VERSION if ( localKdeDir.startsWith( "LOCAL:" ) ) { #ifdef _WIN32_ localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 ); #else localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 ); #endif qDebug("Using local conf dir %s ",localKdeDir.latin1() ); + // <stdlib.h> + setenv( "LOCALMICROKDEHOME", localKdeDir.latin1(), 1 ); } #endif } } 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) diff --git a/microkde/kdecore/kstandarddirs.h b/microkde/kdecore/kstandarddirs.h index bee864e..901384e 100644 --- a/microkde/kdecore/kstandarddirs.h +++ b/microkde/kdecore/kstandarddirs.h @@ -586,96 +586,100 @@ public: bool addedCustoms; class KStandardDirsPrivate; KStandardDirsPrivate *d; //US static QString mAppDir; void checkConfig() const; void applyDataRestrictions(const QString &) const; //US void createSpecialResource(const char*); }; /** * \addtogroup locates Locate Functions * @{ * On The Usage Of 'locate' and 'locateLocal' * * Typical KDE applications use resource files in one out of * three ways: * * 1) A resource file is read but is never written. A system * default is supplied but the user can override this * default in his local .kde directory: * * \code * // Code example * myFile = locate("appdata", "groups.lst"); * myData = myReadGroups(myFile); // myFile may be null * \endcode * * 2) A resource file is read and written. If the user has no * local version of the file the system default is used. * The resource file is always written to the users local * .kde directory. * * \code * // Code example * myFile = locate("appdata", "groups.lst") * myData = myReadGroups(myFile); * ... * doSomething(myData); * ... * myFile = locateLocal("appdata", "groups.lst"); * myWriteGroups(myFile, myData); * \endcode * * 3) A resource file is read and written. No system default * is used if the user has no local version of the file. * The resource file is always written to the users local * .kde directory. * * \code * // Code example * myFile = locateLocal("appdata", "groups.lst"); * myData = myReadGroups(myFile); * ... * doSomething(myData); * ... * myFile = locateLocal("appdata", "groups.lst"); * myWriteGroups(myFile, myData); * \endcode **/ + /*! * \relates KStandardDirs * This function is just for convenience. It simply calls *instance->dirs()->\link KStandardDirs::findResource() findResource\endlink(type, filename). **/ QString locate( const char *type, const QString& filename /*US , const KInstance* instance = KGlobal::instance()*/ ); /*! * \relates KStandardDirs * This function is much like locate. However it returns a * filename suitable for writing to. No check is made if the * specified filename actually exists. Missing directories * are created. If filename is only a directory, without a * specific file, filename must have a trailing slash. * **/ QString locateLocal( const char *type, const QString& filename /*US , const KInstance* instance = KGlobal::instance() */ ); /*! * \relates KStandardDirs * This function is much like locate. No check is made if the * specified filename actually exists. Missing directories * are created if @p createDir is true. If filename is only * a directory, without a specific file, * filename must have a trailing slash. * **/ QString locateLocal( const char *type, const QString& filename, bool createDir /*US , const KInstance* instance = KGlobal::instance() */); +QString readEnvPath(const char *env); + + /*! @} */ #endif // SSK_KSTDDIRS_H |