summaryrefslogtreecommitdiffstats
path: root/tools/designer/examples/filechooser
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-11-08 12:31:36 -0600
committerTimothy Pearson <[email protected]>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /tools/designer/examples/filechooser
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'tools/designer/examples/filechooser')
-rw-r--r--tools/designer/examples/filechooser/plugin/plugin.cpp95
-rw-r--r--tools/designer/examples/filechooser/plugin/plugin.h16
-rw-r--r--tools/designer/examples/filechooser/plugin/plugin.pro14
-rw-r--r--tools/designer/examples/filechooser/widget/filechooser.cpp62
-rw-r--r--tools/designer/examples/filechooser/widget/filechooser.h48
-rw-r--r--tools/designer/examples/filechooser/widget/filechooser.pro9
-rw-r--r--tools/designer/examples/filechooser/widget/main.cpp10
7 files changed, 254 insertions, 0 deletions
diff --git a/tools/designer/examples/filechooser/plugin/plugin.cpp b/tools/designer/examples/filechooser/plugin/plugin.cpp
new file mode 100644
index 000000000..4f7334c8d
--- /dev/null
+++ b/tools/designer/examples/filechooser/plugin/plugin.cpp
@@ -0,0 +1,95 @@
+#include "plugin.h"
+#include "../widget/filechooser.h"
+
+static const char *filechooser_pixmap[] = {
+ "22 22 8 1",
+ " c Gray100",
+ ". c Gray97",
+ "X c #4f504f",
+ "o c #00007f",
+ "O c Gray0",
+ "+ c none",
+ "@ c Gray0",
+ "# c Gray0",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "+OOOOOOOOOOOOOOOOOOOO+",
+ "OOXXXXXXXXXXXXXXXXXXOO",
+ "OXX. OO OO O",
+ "OX. oo O O",
+ "OX. oo O .O",
+ "OX ooo oooo O O",
+ "OX oo oo oo O O",
+ "OX oooo oo oo O O",
+ "OX oo oo oo oo O O",
+ "OX oo oo oo oo O O",
+ "OX oooo oooo O O",
+ "OX OO OO O",
+ "OO..................OO",
+ "+OOOOOOOOOOOOOOOOOOOO+",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++"
+};
+
+CustomWidgetPlugin::CustomWidgetPlugin()
+{
+}
+
+TQStringList CustomWidgetPlugin::keys() const
+{
+ TQStringList list;
+ list << "FileChooser";
+ return list;
+}
+
+TQWidget* CustomWidgetPlugin::create( const TQString &key, TQWidget* parent, const char* name )
+{
+ if ( key == "FileChooser" )
+ return new FileChooser( parent, name );
+ return 0;
+}
+
+TQString CustomWidgetPlugin::group( const TQString& feature ) const
+{
+ if ( feature == "FileChooser" )
+ return "Input";
+ return TQString::null;
+}
+
+TQIconSet CustomWidgetPlugin::iconSet( const TQString& ) const
+{
+ return TQIconSet( TQPixmap( filechooser_pixmap ) );
+}
+
+TQString CustomWidgetPlugin::includeFile( const TQString& feature ) const
+{
+ if ( feature == "FileChooser" )
+ return "filechooser.h";
+ return TQString::null;
+}
+
+TQString CustomWidgetPlugin::toolTip( const TQString& feature ) const
+{
+ if ( feature == "FileChooser" )
+ return "File Chooser Widget";
+ return TQString::null;
+}
+
+TQString CustomWidgetPlugin::whatsThis( const TQString& feature ) const
+{
+ if ( feature == "FileChooser" )
+ return "A widget to choose a file or directory";
+ return TQString::null;
+}
+
+bool CustomWidgetPlugin::isContainer( const TQString& ) const
+{
+ return FALSE;
+}
+
+
+Q_EXPORT_PLUGIN( CustomWidgetPlugin )
diff --git a/tools/designer/examples/filechooser/plugin/plugin.h b/tools/designer/examples/filechooser/plugin/plugin.h
new file mode 100644
index 000000000..11262f830
--- /dev/null
+++ b/tools/designer/examples/filechooser/plugin/plugin.h
@@ -0,0 +1,16 @@
+#include <qwidgetplugin.h>
+
+class CustomWidgetPlugin : public TQWidgetPlugin
+{
+public:
+ CustomWidgetPlugin();
+
+ TQStringList keys() const;
+ TQWidget* create( const TQString &classname, TQWidget* parent = 0, const char* name = 0 );
+ TQString group( const TQString& ) const;
+ TQIconSet iconSet( const TQString& ) const;
+ TQString includeFile( const TQString& ) const;
+ TQString toolTip( const TQString& ) const;
+ TQString whatsThis( const TQString& ) const;
+ bool isContainer( const TQString& ) const;
+};
diff --git a/tools/designer/examples/filechooser/plugin/plugin.pro b/tools/designer/examples/filechooser/plugin/plugin.pro
new file mode 100644
index 000000000..012f1852e
--- /dev/null
+++ b/tools/designer/examples/filechooser/plugin/plugin.pro
@@ -0,0 +1,14 @@
+TEMPLATE = lib
+LANGUAGE = C++
+TARGET = filechooser
+
+SOURCES += plugin.cpp ../widget/filechooser.cpp
+HEADERS += plugin.h ../widget/filechooser.h
+DESTDIR = ../../../../../plugins/designer
+
+target.path=$$plugins.path
+
+INSTALLS += target
+CONFIG += qt warn_on release plugin
+INCLUDEPATH += $$QT_SOURCE_TREE/tools/designer/interfaces
+DBFILE = plugin.db
diff --git a/tools/designer/examples/filechooser/widget/filechooser.cpp b/tools/designer/examples/filechooser/widget/filechooser.cpp
new file mode 100644
index 000000000..c082b9430
--- /dev/null
+++ b/tools/designer/examples/filechooser/widget/filechooser.cpp
@@ -0,0 +1,62 @@
+#include "filechooser.h"
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qfiledialog.h>
+#include <qlayout.h>
+
+FileChooser::FileChooser( TQWidget *parent, const char *name )
+ : TQWidget( parent, name ), md( File )
+{
+ TQHBoxLayout *layout = new TQHBoxLayout( this );
+ layout->setMargin( 0 );
+
+ lineEdit = new TQLineEdit( this, "filechooser_lineedit" );
+ layout->addWidget( lineEdit );
+
+ connect( lineEdit, SIGNAL( textChanged( const TQString & ) ),
+ this, SIGNAL( fileNameChanged( const TQString & ) ) );
+
+ button = new TQPushButton( "...", this, "filechooser_button" );
+ button->setFixedWidth( button->fontMetrics().width( " ... " ) );
+ layout->addWidget( button );
+
+ connect( button, SIGNAL( clicked() ),
+ this, SLOT( chooseFile() ) );
+
+ setFocusProxy( lineEdit );
+}
+
+void FileChooser::setMode( Mode m )
+{
+ md = m;
+}
+
+FileChooser::Mode FileChooser::mode() const
+{
+ return md;
+}
+
+void FileChooser::setFileName( const TQString &fn )
+{
+ lineEdit->setText( fn );
+}
+
+TQString FileChooser::fileName() const
+{
+ return lineEdit->text();
+}
+
+void FileChooser::chooseFile()
+{
+ TQString fn;
+ if ( mode() == File )
+ fn = TQFileDialog::getOpenFileName( lineEdit->text(), TQString::null, this );
+ else
+ fn = TQFileDialog::getExistingDirectory( lineEdit->text(),this );
+
+ if ( !fn.isEmpty() ) {
+ lineEdit->setText( fn );
+ emit fileNameChanged( fn );
+ }
+}
+
diff --git a/tools/designer/examples/filechooser/widget/filechooser.h b/tools/designer/examples/filechooser/widget/filechooser.h
new file mode 100644
index 000000000..cff0af536
--- /dev/null
+++ b/tools/designer/examples/filechooser/widget/filechooser.h
@@ -0,0 +1,48 @@
+#ifndef FILECHOOSER_H
+#define FILECHOOSER_H
+
+#include <qwidget.h>
+#include <qwidgetplugin.h>
+
+class TQLineEdit;
+class TQPushButton;
+
+#ifdef FILECHOOSER_IS_WIDGET
+#undef QT_WIDGET_PLUGIN_EXPORT
+#define QT_WIDGET_PLUGIN_EXPORT
+#endif
+
+class QT_WIDGET_PLUGIN_EXPORT FileChooser : public TQWidget
+{
+ Q_OBJECT
+
+ Q_ENUMS( Mode )
+ Q_PROPERTY( Mode mode READ mode WRITE setMode )
+ Q_PROPERTY( TQString fileName READ fileName WRITE setFileName )
+
+public:
+ FileChooser( TQWidget *parent = 0, const char *name = 0);
+
+ enum Mode { File, Directory };
+
+ TQString fileName() const;
+ Mode mode() const;
+
+public slots:
+ void setFileName( const TQString &fn );
+ void setMode( Mode m );
+
+signals:
+ void fileNameChanged( const TQString & );
+
+private slots:
+ void chooseFile();
+
+private:
+ TQLineEdit *lineEdit;
+ TQPushButton *button;
+ Mode md;
+
+};
+
+#endif
diff --git a/tools/designer/examples/filechooser/widget/filechooser.pro b/tools/designer/examples/filechooser/widget/filechooser.pro
new file mode 100644
index 000000000..20ea7872b
--- /dev/null
+++ b/tools/designer/examples/filechooser/widget/filechooser.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+LANGUAGE = C++
+TARGET = filechooser
+
+SOURCES += filechooser.cpp main.cpp
+HEADERS += filechooser.h
+CONFIG += qt warn_on release
+DBFILE = filechooser.db
+DEFINES += FILECHOOSER_IS_WIDGET
diff --git a/tools/designer/examples/filechooser/widget/main.cpp b/tools/designer/examples/filechooser/widget/main.cpp
new file mode 100644
index 000000000..2742db74c
--- /dev/null
+++ b/tools/designer/examples/filechooser/widget/main.cpp
@@ -0,0 +1,10 @@
+#include <qapplication.h>
+#include "filechooser.h"
+
+int main( int argc, char ** argv )
+{
+ TQApplication a( argc, argv );
+ FileChooser *fc = new FileChooser;
+ fc->show();
+ return a.exec();
+}