diff options
Diffstat (limited to 'ksquirrel/sidebar/sq_categorybrowsermenu.cpp')
-rw-r--r-- | ksquirrel/sidebar/sq_categorybrowsermenu.cpp | 128 |
1 files changed, 63 insertions, 65 deletions
diff --git a/ksquirrel/sidebar/sq_categorybrowsermenu.cpp b/ksquirrel/sidebar/sq_categorybrowsermenu.cpp index da384dd..a8884a1 100644 --- a/ksquirrel/sidebar/sq_categorybrowsermenu.cpp +++ b/ksquirrel/sidebar/sq_categorybrowsermenu.cpp @@ -32,8 +32,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "config.h" #endif -#include <qpixmap.h> -#include <qdir.h> +#include <tqpixmap.h> +#include <tqdir.h> #include <kglobal.h> #include <kconfig.h> @@ -59,32 +59,32 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define CICON(a) (*_icons)[a] -QMap<QString, QPixmap> *SQ_CategoryBrowserMenu::_icons = 0; +TQMap<TQString, TQPixmap> *SQ_CategoryBrowserMenu::_icons = 0; -SQ_CategoryBrowserMenu::SQ_CategoryBrowserMenu(QString path, QWidget *parent, const char *name, int startid) - : KPanelMenu(path, parent, name) +SQ_CategoryBrowserMenu::SQ_CategoryBrowserMenu(TQString path, TQWidget *tqparent, const char *name, int startid) + : KPanelMenu(path, tqparent, name) , _mimecheckTimer(0) , _startid(startid) , _dirty(false) { _subMenus.setAutoDelete(true); - _lastpress = QPoint(-1, -1); + _lastpress = TQPoint(-1, -1); setAcceptDrops(true); // Should depend on permissions of path. // we are not interested for dirty events on files inside the // directory (see slotClearIfNeeded) - connect( &_dirWatch, SIGNAL(dirty(const QString&)), - this, SLOT(slotClearIfNeeded(const QString&)) ); - connect( &_dirWatch, SIGNAL(created(const QString&)), - this, SLOT(slotClear()) ); - connect( &_dirWatch, SIGNAL(deleted(const QString&)), - this, SLOT(slotClear()) ); + connect( &_dirWatch, TQT_SIGNAL(dirty(const TQString&)), + this, TQT_SLOT(slotClearIfNeeded(const TQString&)) ); + connect( &_dirWatch, TQT_SIGNAL(created(const TQString&)), + this, TQT_SLOT(slotClear()) ); + connect( &_dirWatch, TQT_SIGNAL(deleted(const TQString&)), + this, TQT_SLOT(slotClear()) ); } SQ_CategoryBrowserMenu::~SQ_CategoryBrowserMenu() {} -void SQ_CategoryBrowserMenu::slotClearIfNeeded(const QString& p) +void SQ_CategoryBrowserMenu::slotClearIfNeeded(const TQString& p) { if (p == path()) slotClear(); @@ -93,7 +93,7 @@ void SQ_CategoryBrowserMenu::slotClearIfNeeded(const QString& p) void SQ_CategoryBrowserMenu::initialize() { - _lastpress = QPoint(-1, -1); + _lastpress = TQPoint(-1, -1); // don't change menu if already visible if (isVisible()) @@ -126,11 +126,11 @@ void SQ_CategoryBrowserMenu::initialize() _filemap.clear(); _mimemap.clear(); - int filter = QDir::Dirs | QDir::Files; + int filter = TQDir::Dirs | TQDir::Files; if(_showhidden) - filter |= QDir::Hidden; + filter |= TQDir::Hidden; - QDir dir(path(), QString::null, QDir::DirsFirst | QDir::Name | QDir::IgnoreCase, filter); + TQDir dir(path(), TQString(), TQDir::DirsFirst | TQDir::Name | TQDir::IgnoreCase, filter); // does the directory exist? if (!dir.exists()) { @@ -139,7 +139,7 @@ void SQ_CategoryBrowserMenu::initialize() } // get entry list - const QFileInfoList *list = dir.entryInfoList(); + const TQFileInfoList *list = dir.entryInfoList(); // no list -> read error if (!list) { @@ -164,7 +164,7 @@ void SQ_CategoryBrowserMenu::initialize() if(dir.root() != path()) { insertTitle(path().right(path().length() - dir.root().length())); - insertItem(CICON("bookmark_add"), i18n("Add here"), this, SLOT(slotAddToCategory())); + insertItem(CICON("bookmark_add"), i18n("Add here"), this, TQT_SLOT(slotAddToCategory())); } } @@ -174,7 +174,7 @@ void SQ_CategoryBrowserMenu::initialize() int run_id = _startid; // get list iterator - QFileInfoListIterator it(*list); + TQFileInfoListIterator it(*list); // jump to startid it += _startid; @@ -185,20 +185,20 @@ void SQ_CategoryBrowserMenu::initialize() // bump id run_id++; - QFileInfo *fi = it.current(); + TQFileInfo *fi = it.current(); // handle directories if (fi->isDir()) { - QString name = fi->fileName(); + TQString name = fi->fileName(); // ignore . and .. entries if (name == "." || name == "..") continue; - QPixmap icon; - QString path = fi->absFilePath(); + TQPixmap icon; + TQString path = fi->absFilePath(); // parse .directory if it does exist - if (QFile::exists(path + "/.directory")) { + if (TQFile::exists(path + "/.directory")) { KSimpleConfig c(path + "/.directory", true); c.setDesktopGroup(); @@ -234,14 +234,14 @@ void SQ_CategoryBrowserMenu::initialize() // handle files else if(fi->isFile()) { - QString name = fi->fileName(); - QString title = KIO::decodeFileName(name); + TQString name = fi->fileName(); + TQString title = KIO::decodeFileName(name); // ignore .directory and .order files if (name == ".directory" || name == ".order") continue; - QPixmap icon; - QString path = fi->absFilePath(); + TQPixmap icon; + TQString path = fi->absFilePath(); bool mimecheck = false; @@ -252,13 +252,13 @@ void SQ_CategoryBrowserMenu::initialize() c.setDesktopGroup(); title = c.readEntry("Name", title); - QString s = c.readEntry("Icon"); - if(!_icons->contains(s)) { + TQString s = c.readEntry("Icon"); + if(!_icons->tqcontains(s)) { icon = KGlobal::iconLoader()->loadIcon(s, KIcon::Small, KIcon::SizeSmall, KIcon::DefaultState, 0, true); if(icon.isNull()) { - QString type = c.readEntry("Type", "Application"); + TQString type = c.readEntry("Type", "Application"); if (type == "Directory") icon = CICON("folder"); else if (type == "Mimetype") @@ -323,7 +323,7 @@ void SQ_CategoryBrowserMenu::initialize() adjustSize(); - QString dirname = path(); + TQString dirname = path(); int maxlen = contentsRect().width() - 40; if(item_count == 0) @@ -340,18 +340,18 @@ void SQ_CategoryBrowserMenu::initialize() if(_mimemap.count() > 0) { if(!_mimecheckTimer) - _mimecheckTimer = new QTimer(this); + _mimecheckTimer = new TQTimer(this); - connect(_mimecheckTimer, SIGNAL(timeout()), SLOT(slotMimeCheck())); + connect(_mimecheckTimer, TQT_SIGNAL(timeout()), TQT_SLOT(slotMimeCheck())); _mimecheckTimer->start(0); } } -void SQ_CategoryBrowserMenu::append(const QPixmap &pixmap, const QString &title, const QString &file, bool mimecheck) +void SQ_CategoryBrowserMenu::append(const TQPixmap &pixmap, const TQString &title, const TQString &file, bool mimecheck) { // avoid &'s being converted to accelerators - QString newTitle = title; - newTitle.replace("&", "&&"); + TQString newTitle = title; + newTitle.tqreplace("&", "&&"); newTitle = KStringHandler::cEmSqueeze( newTitle, fontMetrics(), 20 ); // insert menu item @@ -365,11 +365,11 @@ void SQ_CategoryBrowserMenu::append(const QPixmap &pixmap, const QString &title, _mimemap.insert(id, true); } -void SQ_CategoryBrowserMenu::append(const QPixmap &pixmap, const QString &title, SQ_CategoryBrowserMenu *subMenu) +void SQ_CategoryBrowserMenu::append(const TQPixmap &pixmap, const TQString &title, SQ_CategoryBrowserMenu *subMenu) { // avoid &'s being converted to accelerators - QString newTitle = title; - newTitle.replace("&", "&&"); + TQString newTitle = title; + newTitle.tqreplace("&", "&&"); newTitle = KStringHandler::cEmSqueeze( newTitle, fontMetrics(), 20 ); // insert submenu @@ -378,28 +378,28 @@ void SQ_CategoryBrowserMenu::append(const QPixmap &pixmap, const QString &title, _subMenus.append(subMenu); } -void SQ_CategoryBrowserMenu::mousePressEvent(QMouseEvent *e) +void SQ_CategoryBrowserMenu::mousePressEvent(TQMouseEvent *e) { - QPopupMenu::mousePressEvent(e); + TQPopupMenu::mousePressEvent(e); _lastpress = e->pos(); } -void SQ_CategoryBrowserMenu::mouseMoveEvent(QMouseEvent *e) +void SQ_CategoryBrowserMenu::mouseMoveEvent(TQMouseEvent *e) { - QPopupMenu::mouseMoveEvent(e); + TQPopupMenu::mouseMoveEvent(e); - if (!(e->state() & LeftButton)) return; - if(_lastpress == QPoint(-1, -1)) return; + if (!(e->state() & Qt::LeftButton)) return; + if(_lastpress == TQPoint(-1, -1)) return; // DND delay if((_lastpress - e->pos()).manhattanLength() < 12) return; // get id int id = idAt(_lastpress); - if(!_filemap.contains(id)) return; + if(!_filemap.tqcontains(id)) return; // reset _lastpress - _lastpress = QPoint(-1, -1); + _lastpress = TQPoint(-1, -1); // start drag KURL url; @@ -410,16 +410,16 @@ void SQ_CategoryBrowserMenu::mouseMoveEvent(QMouseEvent *e) d->drag(); } -void SQ_CategoryBrowserMenu::dragEnterEvent( QDragEnterEvent *ev ) +void SQ_CategoryBrowserMenu::dragEnterEvent( TQDragEnterEvent *ev ) { if (KURLDrag::canDecode(ev)) ev->accept(rect()); KPanelMenu::dragEnterEvent(ev); } -void SQ_CategoryBrowserMenu::dropEvent( QDropEvent *ev ) +void SQ_CategoryBrowserMenu::dropEvent( TQDropEvent *ev ) { - KFileItem item( path(), QString::fromLatin1( "inode/directory" ), KFileItem::Unknown ); + KFileItem item( path(), TQString::tqfromLatin1( "inode/directory" ), KFileItem::Unknown ); KonqOperations::doDrop( &item, path(), ev, this ); KPanelMenu::dropEvent(ev); // ### TODO: Update list @@ -429,12 +429,12 @@ void SQ_CategoryBrowserMenu::slotExec(int id) { kapp->propagateSessionManager(); - if(!_filemap.contains(id)) return; + if(!_filemap.tqcontains(id)) return; KURL url; url.setPath(path() + '/' + _filemap[id]); new KRun(url, 0, true); // will delete itself - _lastpress = QPoint(-1, -1); + _lastpress = TQPoint(-1, -1); } void SQ_CategoryBrowserMenu::slotAddToCategory() @@ -445,7 +445,7 @@ void SQ_CategoryBrowserMenu::slotAddToCategory() void SQ_CategoryBrowserMenu::slotMimeCheck() { // get the first map entry - QMap<int, bool>::Iterator it = _mimemap.begin(); + TQMap<int, bool>::Iterator it = _mimemap.begin(); // no mime types left to check -> stop timer if(it == _mimemap.end()) { @@ -454,7 +454,7 @@ void SQ_CategoryBrowserMenu::slotMimeCheck() } int id = it.key(); - QString file = _filemap[id]; + TQString file = _filemap[id]; _mimemap.remove(it); @@ -462,23 +462,21 @@ void SQ_CategoryBrowserMenu::slotMimeCheck() url.setPath( path() + '/' + file ); // KMimeType::Ptr mt = KMimeType::findByURL(url, 0, true, false); -// QString icon(mt->icon(url, true)); - QString icon = KMimeType::iconForURL( url ); +// TQString icon(mt->icon(url, true)); + TQString icon = KMimeType::iconForURL( url ); // kdDebug() << url.url() << ": " << icon << endl; file = KStringHandler::cEmSqueeze( file, fontMetrics(), 20 ); - file.replace("&", "&&"); - if(!_icons->contains(icon)) { - QPixmap pm = SmallIcon(icon); -#if ( QT_VERSION >= 0x030200 ) + file.tqreplace("&", "&&"); + if(!_icons->tqcontains(icon)) { + TQPixmap pm = SmallIcon(icon); if( pm.height() > 16 ) { - QPixmap cropped( 16, 16 ); + TQPixmap cropped( 16, 16 ); copyBlt( &cropped, 0, 0, &pm, 0, 0, 16, 16 ); pm = cropped; } -#endif _icons->insert(icon, pm); changeItem(id, pm, file); } @@ -507,7 +505,7 @@ void SQ_CategoryBrowserMenu::initIconMap() // kdDebug() << "SQ_CategoryBrowserMenu::initIconMap" << endl; - _icons = new QMap<QString, QPixmap>; + _icons = new TQMap<TQString, TQPixmap>; _icons->insert("folder", SmallIcon("folder")); _icons->insert("unknown", SmallIcon("mime_empty")); |