Source: kopenwith.h


Annotated List
Files
Globals
Hierarchy
Index
// "$Id: kopenwith.h,v 1.16 2000/03/24 02:20:31 reiher Exp $"

#ifndef __open_with_h__
#define __open_with_h__

#include <qwidget.h>
#include <qfileinfo.h>
#include <qdialog.h>

#include <kapp.h>
#include <klineedit.h>
#include <kurl.h>
#include <kurlcompletion.h>
#include <klistview.h>

#include "kservice.h"

class KApplicationTree;

class QCheckBox;
class QPushButton;
class QLabel;
class QStringList;

/* ------------------------------------------------------------------------- */

/**
 * "Open with" dialog box.
 * Used automatically by KRun, and used by libkonq.
 */
class KOpenWithDlg : public QDialog
{
    Q_OBJECT
public:
    /**
     * Create a dialog that asks for a application to open a given URL(s) with.
     *
     * @param urls   is the URL that should be opened
     * @param text   appears as a label on top of the entry box.
     * @param value  is the initial value of the line
     * @param parent parent widget
     */

    KOpenWithDlg( const KURL::List& urls, const QString&text, const QString&value, QWidget *parent );
    ~KOpenWithDlg();

    /**
     * @return the value the user entered
     */
    QString text() { return edit->text(); }
    KService::Ptr service() { return m_pService; }

public slots:
    /**
    * The slot for clearing the edit widget
    */
    void slotClear();
    void slotSelected( const QString&_name, const QString& _exec );
    void slotHighlighted( const QString& _name, const QString& _exec );
    void slotOK();

protected:
    KLineEdit *edit;
    KURLCompletion * completion;

    KApplicationTree* m_pTree;
    QLabel *label;

    QString qName, qServiceType;
    bool  haveApp;
    QCheckBox   *terminal, *remember;
    QPushButton *ok;
    QPushButton *clear;
    QPushButton *cancel;

    KService::Ptr m_pService;
};


/* ------------------------------------------------------------------------- */

class KAppTreeListItem : public QListViewItem
{
    bool parsed;
    bool directory;
    QString path;
    QString exec;

protected:
    QString key(int column, bool ascending) const;

    void init(const QPixmap& pixmap, bool parse, bool dir, QString _path, QString exec);

public:
    KAppTreeListItem( KListView* parent, const char *name, const QPixmap& pixmap,
                      bool parse, bool dir, QString p, QString c );
    KAppTreeListItem( QListViewItem* parent, const char *name, const QPixmap& pixmap,
                      bool parse, bool dir, QString p, QString c );

protected:
    virtual void activate();
    virtual void setOpen( bool o );

    friend KApplicationTree;
};

/* ------------------------------------------------------------------------- */

class KApplicationTree : public KListView
{
    Q_OBJECT
public:
    KApplicationTree( QWidget *parent );

    bool isDesktopFile( const QString& filename );

    /**
     * Parse a single .desktop/.kdelnk file
     */
    void parseDesktopFile( QFileInfo *fi, KAppTreeListItem *item, QString relPath );
    /**
     * Parse a directory for .desktop/.kdelnk files
     */
    void parseDesktopDir( QString relPath, KAppTreeListItem *item = 0 );

    KAppTreeListItem *it;

protected:
    void resizeEvent( QResizeEvent *_ev );

public slots:
    void slotItemHighlighted(QListViewItem* i);
    void slotSelectionChanged(QListViewItem* i);

signals:
    void selected( const QString& _name, const QString& _exec );
    void highlighted( const QString& _name, const  QString& _exec );
};

/* ------------------------------------------------------------------------- */

#endif

Generated by: dfaure@faure on Sun Mar 26 14:24:43 2000, using kdoc 2.0a35.