diff options
Diffstat (limited to 'kexi/main/startup/KexiStartupFileDialog.cpp')
-rw-r--r-- | kexi/main/startup/KexiStartupFileDialog.cpp | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/kexi/main/startup/KexiStartupFileDialog.cpp b/kexi/main/startup/KexiStartupFileDialog.cpp index d2869925..c19a96c0 100644 --- a/kexi/main/startup/KexiStartupFileDialog.cpp +++ b/kexi/main/startup/KexiStartupFileDialog.cpp @@ -23,10 +23,10 @@ #include <core/kexi.h> #include <kexiutils/utils.h> -#include <qlayout.h> -#include <qobjectlist.h> -#include <qpushbutton.h> -#include <qapplication.h> +#include <tqlayout.h> +#include <tqobjectlist.h> +#include <tqpushbutton.h> +#include <tqapplication.h> #include <kmessagebox.h> #include <klocale.h> @@ -36,46 +36,46 @@ #include <kurlcombobox.h> KexiStartupFileDialog::KexiStartupFileDialog( - const QString& startDirOrVariable, int mode, - QWidget *parent, const char *name) - : KexiStartupFileDialogBase(startDirOrVariable, "", parent, name, 0) + const TQString& startDirOrVariable, int mode, + TQWidget *tqparent, const char *name) + : KexiStartupFileDialogBase(startDirOrVariable, "", tqparent, name, 0) , m_confirmOverwrites(true) , m_filtersUpdated(false) { - setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); + tqsetSizePolicy(TQSizePolicy::Minimum,TQSizePolicy::Minimum); setMode( mode ); - QPoint point( 0, 0 ); - reparent( parentWidget(), point ); + TQPoint point( 0, 0 ); + reparent( tqparentWidget(), point ); - if (layout()) - layout()->setMargin(0); + if (tqlayout()) + tqlayout()->setMargin(0); setMinimumHeight(100); setSizeGripEnabled ( false ); //dirty hack to customize filedialog view: { - QObjectList *l = queryList( "QPushButton" ); - QObjectListIt it( *l ); - QObject *obj; + TQObjectList *l = queryList( TQPUSHBUTTON_OBJECT_NAME_STRING ); + TQObjectListIt it( *l ); + TQObject *obj; while ( (obj = it.current()) != 0 ) { ++it; - static_cast<QPushButton*>(obj)->hide(); + static_cast<TQPushButton*>(TQT_TQWIDGET(obj))->hide(); } delete l; } { - QObjectList *l = queryList("QWidget"); - QObjectListIt it( *l ); - QObject *obj; + TQObjectList *l = queryList(TQWIDGET_OBJECT_NAME_STRING); + TQObjectListIt it( *l ); + TQObject *obj; while ( (obj = it.current()) != 0 ) { ++it; - static_cast<QWidget*>(obj)->installEventFilter(this); + TQT_TQWIDGET(obj)->installEventFilter(this); } delete l; } -#ifdef Q_WS_WIN +#ifdef TQ_WS_WIN if (startDirOrVariable.startsWith(":")) m_lastVisitedPathsVariable = startDirOrVariable; //store for later use #else @@ -86,7 +86,7 @@ KexiStartupFileDialog::KexiStartupFileDialog( KexiStartupFileDialog::~KexiStartupFileDialog() { -#ifdef Q_WS_WIN +#ifdef TQ_WS_WIN saveLastVisitedPath(currentFileName()); #endif } @@ -98,24 +98,24 @@ void KexiStartupFileDialog::setMode(int mode) m_filtersUpdated = false; } -QStringList KexiStartupFileDialog::additionalFilters() const +TQStringList KexiStartupFileDialog::additionalFilters() const { return m_additionalMimeTypes; } -void KexiStartupFileDialog::setAdditionalFilters(const QStringList &mimeTypes) +void KexiStartupFileDialog::setAdditionalFilters(const TQStringList &mimeTypes) { //delayed m_additionalMimeTypes = mimeTypes; m_filtersUpdated = false; } -QStringList KexiStartupFileDialog::excludedFilters() const +TQStringList KexiStartupFileDialog::excludedFilters() const { return m_excludedMimeTypes; } -void KexiStartupFileDialog::setExcludedFilters(const QStringList &mimeTypes) +void KexiStartupFileDialog::setExcludedFilters(const TQStringList &mimeTypes) { //delayed m_excludedMimeTypes = mimeTypes; @@ -128,35 +128,35 @@ void KexiStartupFileDialog::updateFilters() return; m_filtersUpdated = true; - m_lastFileName = QString::null; + m_lastFileName = TQString(); // m_lastUrl = KURL(); clearFilter(); - QString filter; + TQString filter; KMimeType::Ptr mime; - QStringList allfilters; + TQStringList allfilters; const bool normalOpeningMode = m_mode & Opening && !(m_mode & Custom); const bool normalSavingMode = m_mode & SavingFileBasedDB && !(m_mode & Custom); if (normalOpeningMode || normalSavingMode) { mime = KMimeType::mimeType( KexiDB::Driver::defaultFileBasedDriverMimeType() ); - if (mime && m_excludedMimeTypes.find(mime->name())==m_excludedMimeTypes.end()) { + if (mime && m_excludedMimeTypes.tqfind(mime->name())==m_excludedMimeTypes.end()) { filter += KexiUtils::fileDialogFilterString(mime); allfilters += mime->patterns(); } } if (normalOpeningMode || m_mode & SavingServerBasedDB) { mime = KMimeType::mimeType("application/x-kexiproject-shortcut"); - if (mime && m_excludedMimeTypes.find(mime->name())==m_excludedMimeTypes.end()) { + if (mime && m_excludedMimeTypes.tqfind(mime->name())==m_excludedMimeTypes.end()) { filter += KexiUtils::fileDialogFilterString(mime); allfilters += mime->patterns(); } } if (normalOpeningMode || m_mode & SavingServerBasedDB) { mime = KMimeType::mimeType("application/x-kexi-connectiondata"); - if (mime && m_excludedMimeTypes.find(mime->name())==m_excludedMimeTypes.end()) { + if (mime && m_excludedMimeTypes.tqfind(mime->name())==m_excludedMimeTypes.end()) { filter += KexiUtils::fileDialogFilterString(mime); allfilters += mime->patterns(); } @@ -165,37 +165,37 @@ void KexiStartupFileDialog::updateFilters() //! @todo hardcoded for MSA: if (normalOpeningMode) { mime = KMimeType::mimeType("application/x-msaccess"); - if (mime && m_excludedMimeTypes.find(mime->name())==m_excludedMimeTypes.end()) { + if (mime && m_excludedMimeTypes.tqfind(mime->name())==m_excludedMimeTypes.end()) { filter += KexiUtils::fileDialogFilterString(mime); allfilters += mime->patterns(); } } - foreach (QStringList::ConstIterator, it, m_additionalMimeTypes) { + foreach (TQStringList::ConstIterator, it, m_additionalMimeTypes) { if (*it == "all/allfiles") continue; - if (m_excludedMimeTypes.find(*it)!=m_excludedMimeTypes.end()) + if (m_excludedMimeTypes.tqfind(*it)!=m_excludedMimeTypes.end()) continue; filter += KexiUtils::fileDialogFilterString(*it); mime = KMimeType::mimeType(*it); allfilters += mime->patterns(); } - if (m_excludedMimeTypes.find("all/allfiles")==m_excludedMimeTypes.end()) + if (m_excludedMimeTypes.tqfind("all/allfiles")==m_excludedMimeTypes.end()) filter += KexiUtils::fileDialogFilterString("all/allfiles"); // mime = KMimeType::mimeType("all/allfiles"); // if (mime) { -// filter += QString(mime->patterns().isEmpty() ? "*" : mime->patterns().join(" ")) +// filter += TQString(mime->patterns().isEmpty() ? "*" : mime->patterns().join(" ")) // + "|" + mime->comment()+ " (*)\n"; // } //remove duplicates made because upper- and lower-case extenstions are used: - QStringList allfiltersUnique; - QDict<char> uniqueDict(499, false); - foreach (QStringList::ConstIterator, it, allfilters) { + TQStringList allfiltersUnique; + TQDict<char> uniqueDict(499, false); + foreach (TQStringList::ConstIterator, it, allfilters) { // kdDebug() << *it << endl; uniqueDict.insert(*it, (char*)1); } - foreach_dict (QDictIterator<char>, it, uniqueDict) { + foreach_dict (TQDictIterator<char>, it, uniqueDict) { allfiltersUnique += it.currentKey(); } allfiltersUnique.sort(); @@ -226,22 +226,22 @@ void KexiStartupFileDialog::show() } //KURL KexiStartupFileDialog::currentURL() -QString KexiStartupFileDialog::currentFileName() +TQString KexiStartupFileDialog::currentFileName() { - setResult( QDialog::Accepted ); // selectedURL tests for it + setResult( TQDialog::Accepted ); // selectedURL tests for it -#ifdef Q_WS_WIN -// QString path = selectedFile(); +#ifdef TQ_WS_WIN +// TQString path = selectedFile(); //js @todo // kdDebug() << "selectedFile() == " << path << " '" << url().fileName() << "' " << m_lineEdit->text() << endl; - QString path = dir()->absPath(); + TQString path = dir()->absPath(); if (!path.endsWith("/") && !path.endsWith("\\")) path.append("/"); path += m_lineEdit->text(); -// QString path = QFileInfo(selectedFile()).dirPath(true) + "/" + m_lineEdit->text(); +// TQString path = TQFileInfo(selectedFile()).dirPath(true) + "/" + m_lineEdit->text(); #else -// QString path = locationEdit->currentText().stripWhiteSpace(); //url.path().stripWhiteSpace(); that does not work, if the full path is not in the location edit !!!!! - QString path=KexiStartupFileDialogBase::selectedURL().path(); +// TQString path = locationEdit->currentText().stripWhiteSpace(); //url.path().stripWhiteSpace(); that does not work, if the full path is not in the location edit !!!!! + TQString path=KexiStartupFileDialogBase::selectedURL().path(); kdDebug() << "prev selectedURL() == " << path <<endl; kdDebug() << "locationEdit == " << locationEdit->currentText().stripWhiteSpace() <<endl; //make sure user-entered path is acceped: @@ -254,22 +254,22 @@ QString KexiStartupFileDialog::currentFileName() if (!currentFilter().isEmpty()) { if (m_mode & SavingFileBasedDB) { - QStringList filters = QStringList::split(" ", currentFilter()); //.first().stripWhiteSpace(); + TQStringList filters = TQStringList::split(" ", currentFilter()); //.first().stripWhiteSpace(); kdDebug()<< " filter == " << filters << endl; - QString ext = QFileInfo(path).extension(false); + TQString ext = TQFileInfo(path).extension(false); bool hasExtension = false; - for (QStringList::ConstIterator filterIt = filters.constBegin(); + for (TQStringList::ConstIterator filterIt = filters.constBegin(); filterIt != filters.constEnd() && !hasExtension; ++filterIt) { - QString f( (*filterIt).stripWhiteSpace() ); + TQString f( (*filterIt).stripWhiteSpace() ); hasExtension = !f.mid(2).isEmpty() && ext==f.mid(2); } if (!hasExtension) { //no extension: add one - QString defaultExtension( m_defaultExtension ); + TQString defaultExtension( m_defaultExtension ); if (defaultExtension.isEmpty()) defaultExtension = filters.first().stripWhiteSpace().mid(2); //first one - path+=(QString(".")+defaultExtension); + path+=(TQString(".")+defaultExtension); kdDebug() << "KexiStartupFileDialog::checkURL(): append extension, " << path << endl; setSelection( path ); } @@ -284,8 +284,8 @@ QString KexiStartupFileDialog::currentFileName() bool KexiStartupFileDialog::checkFileName() { // KURL url = currentURL(); -// QString path = url.path().stripWhiteSpace(); - QString path = currentFileName().stripWhiteSpace(); +// TQString path = url.path().stripWhiteSpace(); + TQString path = currentFileName().stripWhiteSpace(); // if (url.fileName().stripWhiteSpace().isEmpty()) { if (path.isEmpty()) { @@ -296,11 +296,11 @@ bool KexiStartupFileDialog::checkFileName() kdDebug() << "KexiStartupFileDialog::checkURL() path: " << path << endl; // kdDebug() << "KexiStartupFileDialog::checkURL() fname: " << url.fileName() << endl; //todo if ( url.isLocalFile() ) { - QFileInfo fi(path); + TQFileInfo fi(path); if (mode() & KFile::ExistingOnly) { if ( !fi.exists() ) { KMessageBox::error( this, "<qt>"+i18n( "The file \"%1\" does not exist." ) - .arg( QDir::convertSeparators(path) ) ); + .tqarg( TQDir::convertSeparators(path) ) ); return false; } else if (mode() & KFile::File) { @@ -310,7 +310,7 @@ bool KexiStartupFileDialog::checkFileName() } else if (!fi.isReadable()) { KMessageBox::error( this, "<qt>"+i18n( "The file \"%1\" is not readable." ) - .arg( QDir::convertSeparators(path) ) ); + .tqarg( TQDir::convertSeparators(path) ) ); return false; } } @@ -323,13 +323,13 @@ bool KexiStartupFileDialog::checkFileName() } //static -bool KexiStartupFileDialog::askForOverwriting(const QString& filePath, QWidget *parent) +bool KexiStartupFileDialog::askForOverwriting(const TQString& filePath, TQWidget *tqparent) { - QFileInfo fi(filePath); + TQFileInfo fi(filePath); if (!fi.exists()) return true; - const int res = KMessageBox::warningYesNo( parent, i18n( "The file \"%1\" already exists.\n" - "Do you want to overwrite it?").arg( QDir::convertSeparators(filePath) ), QString::null, + const int res = KMessageBox::warningYesNo( tqparent, i18n( "The file \"%1\" already exists.\n" + "Do you want to overwrite it?").tqarg( TQDir::convertSeparators(filePath) ), TQString(), i18n("Overwrite"), KStdGuiItem::no() ); if (res == KMessageBox::Yes) return true; @@ -339,17 +339,17 @@ bool KexiStartupFileDialog::askForOverwriting(const QString& filePath, QWidget * void KexiStartupFileDialog::accept() { // locationEdit->setFocus(); -// QKeyEvent ev(QEvent::KeyPress, Qt::Key_Enter, '\n', 0); -// QApplication::sendEvent(locationEdit, &ev); -// QApplication::postEvent(locationEdit, &ev); +// TQKeyEvent ev(TQEvent::KeyPress, TQt::Key_Enter, '\n', 0); +// TQApplication::sendEvent(locationEdit, &ev); +// TQApplication::postEvent(locationEdit, &ev); // kdDebug() << "KexiStartupFileDialog::accept() m_lastUrl == " << m_lastUrl.path() << endl; // if (m_lastUrl.path()==currentURL().path()) {//(js) to prevent more multiple kjob signals (I do not know why this is) if (m_lastFileName==currentFileName()) {//(js) to prevent more multiple kjob signals (I do not know why this is) // m_lastUrl=KURL(); - m_lastFileName=QString::null; + m_lastFileName=TQString(); kdDebug() << "m_lastFileName==currentFileName()" << endl; -#ifdef Q_WS_WIN +#ifdef TQ_WS_WIN return; #endif } @@ -365,7 +365,7 @@ void KexiStartupFileDialog::accept() // m_lastUrl = currentURL(); m_lastFileName = currentFileName(); -#ifdef Q_WS_WIN +#ifdef TQ_WS_WIN saveLastVisitedPath(m_lastFileName); #endif } @@ -376,7 +376,7 @@ void KexiStartupFileDialog::reject() emit rejected(); } -/*#ifndef Q_WS_WIN +/*#ifndef TQ_WS_WIN KURLComboBox *KexiStartupFileDialog::locationWidget() const { return locationEdit; @@ -384,9 +384,9 @@ KURLComboBox *KexiStartupFileDialog::locationWidget() const #endif */ -void KexiStartupFileDialog::setLocationText(const QString& fn) +void KexiStartupFileDialog::setLocationText(const TQString& fn) { -#ifdef Q_WS_WIN +#ifdef TQ_WS_WIN //js @todo setSelection(fn); #else @@ -399,19 +399,19 @@ void KexiStartupFileDialog::setLocationText(const QString& fn) void KexiStartupFileDialog::setFocus() { -#ifdef Q_WS_WIN +#ifdef TQ_WS_WIN m_lineEdit->setFocus(); #else locationEdit->setFocus(); #endif } -bool KexiStartupFileDialog::eventFilter ( QObject * watched, QEvent * e ) +bool KexiStartupFileDialog::eventFilter ( TQObject * watched, TQEvent * e ) { //filter-out ESC key - if (e->type()==QEvent::KeyPress && static_cast<QKeyEvent*>(e)->key()==Qt::Key_Escape - && static_cast<QKeyEvent*>(e)->state()==Qt::NoButton) { - static_cast<QKeyEvent*>(e)->accept(); + if (e->type()==TQEvent::KeyPress && TQT_TQKEYEVENT(e)->key()==TQt::Key_Escape + && TQT_TQKEYEVENT(e)->state()==Qt::NoButton) { + TQT_TQKEYEVENT(e)->accept(); emit rejected(); return true; } |