From d796c9dd933ab96ec83b9a634feedd5d32e1ba3f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 12:31:36 -0600 Subject: Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731 --- doc/html/iconview-simple_dd-main-cpp.html | 230 ++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 doc/html/iconview-simple_dd-main-cpp.html (limited to 'doc/html/iconview-simple_dd-main-cpp.html') diff --git a/doc/html/iconview-simple_dd-main-cpp.html b/doc/html/iconview-simple_dd-main-cpp.html new file mode 100644 index 000000000..518dc35c7 --- /dev/null +++ b/doc/html/iconview-simple_dd-main-cpp.html @@ -0,0 +1,230 @@ + + + + + +iconview/simple_dd/main.cpp Example File + + + + + + + +
+ +Home + | +All Classes + | +Main Classes + | +Annotated + | +Grouped Classes + | +Functions +

iconview/simple_dd/main.cpp Example File

+ + +
/****************************************************************************
+** $Id: qt/main.cpp   3.3.8   edited Jan 11 14:37 $
+**
+** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
+**
+** This file is part of an example program for TQt.  This example
+** program may be used, distributed and modified without limitation.
+**
+*****************************************************************************/
+
+#include "main.h"
+
+const char* red_icon[]={
+"16 16 2 1",
+"r c red",
+". c None",
+"................",
+"................",
+"..rrrrrrrrrrrr..",
+"..rrrrrrrrrrrr..",
+"..rrrrrrrrrrrr..",
+"..rrr......rrr..",
+"..rrr......rrr..",
+"..rrr......rrr..",
+"..rrr......rrr..",
+"..rrr......rrr..",
+"..rrr......rrr..",
+"..rrrrrrrrrrrr..",
+"..rrrrrrrrrrrr..",
+"..rrrrrrrrrrrr..",
+"................",
+"................"};
+
+const char* blue_icon[]={
+"16 16 2 1",
+"b c blue",
+". c None",
+"................",
+"................",
+"..bbbbbbbbbbbb..",
+"..bbbbbbbbbbbb..",
+"..bbbbbbbbbbbb..",
+"..bbb......bbb..",
+"..bbb......bbb..",
+"..bbb......bbb..",
+"..bbb......bbb..",
+"..bbb......bbb..",
+"..bbb......bbb..",
+"..bbbbbbbbbbbb..",
+"..bbbbbbbbbbbb..",
+"..bbbbbbbbbbbb..",
+"................",
+"................"};
+
+const char* green_icon[]={
+"16 16 2 1",
+"g c green",
+". c None",
+"................",
+"................",
+"..gggggggggggg..",
+"..gggggggggggg..",
+"..gggggggggggg..",
+"..ggg......ggg..",
+"..ggg......ggg..",
+"..ggg......ggg..",
+"..ggg......ggg..",
+"..ggg......ggg..",
+"..ggg......ggg..",
+"..gggggggggggg..",
+"..gggggggggggg..",
+"..gggggggggggg..",
+"................",
+"................"};
+
+
+// ListBox -- low level drag and drop
+
+DDListBox::DDListBox( TQWidget * parent, const char * name, WFlags f ) :
+    TQListBox( parent, name, f )
+{
+    setAcceptDrops( TRUE );
+    dragging = FALSE;
+}
+
+
+void DDListBox::dragEnterEvent( TQDragEnterEvent *evt )
+{
+    if ( TQTextDrag::canDecode( evt ) )
+        evt->accept();
+}
+
+
+void DDListBox::dropEvent( TQDropEvent *evt )
+{
+    TQString text;
+
+    if ( TQTextDrag::decode( evt, text ) )
+        insertItem( text );
+}
+
+
+void DDListBox::mousePressEvent( TQMouseEvent *evt )
+{
+    TQListBox::mousePressEvent( evt );
+    dragging = TRUE;
+}
+
+
+void DDListBox::mouseMoveEvent( TQMouseEvent * )
+{
+    if ( dragging ) {
+        TQDragObject *d = new TQTextDrag( currentText(), this );
+        d->dragCopy(); // do NOT delete d.
+        dragging = FALSE;
+    }
+}
+
+
+// IconViewIcon -- high level drag and drop
+
+
+bool DDIconViewItem::acceptDrop( const TQMimeSource *mime ) const
+{
+    if ( mime->provides( "text/plain" ) )
+        return TRUE;
+    return FALSE;
+}
+
+
+void DDIconViewItem::dropped( TQDropEvent *evt, const TQValueList<TQIconDragItem>& )
+{
+    TQString label;
+
+    if ( TQTextDrag::decode( evt, label ) )
+        setText( label );
+}
+
+
+// IconView -- high level drag and drop
+
+TQDragObject *DDIconView::dragObject()
+{
+  return new TQTextDrag( currentItem()->text(), this );
+}
+
+void DDIconView::slotNewItem( TQDropEvent *evt, const TQValueList<TQIconDragItem>& )
+{
+    TQString label;
+
+    if ( TQTextDrag::decode( evt, label ) ) {
+        DDIconViewItem *item = new DDIconViewItem( this, label );
+        item->setRenameEnabled( TRUE );
+    }
+}
+
+
+
+int main( int argc, char *argv[] )
+{
+    TQApplication app( argc, argv );
+
+    // Create and show the widgets
+    TQSplitter *split = new TQSplitter();
+    DDIconView *iv   = new DDIconView( split );
+    (void)             new DDListBox( split );
+    app.setMainWidget( split );
+    split->resize( 600, 400 );
+    split->show();
+
+    // Set up the connection so that we can drop items into the icon view
+    TQObject::connect(
+        iv, SIGNAL(dropped(TQDropEvent*, const TQValueList<TQIconDragItem>&)),
+        iv, SLOT(slotNewItem(TQDropEvent*, const TQValueList<TQIconDragItem>&)));
+
+    // Populate the TQIconView with icons
+    DDIconViewItem *item;
+    item = new DDIconViewItem( iv, "Red",   TQPixmap( red_icon ) );
+    item->setRenameEnabled( TRUE );
+    item = new DDIconViewItem( iv, "Green", TQPixmap( green_icon ) );
+    item->setRenameEnabled( TRUE );
+    item = new DDIconViewItem( iv, "Blue",  TQPixmap( blue_icon ) );
+    item->setRenameEnabled( TRUE );
+
+    return app.exec();
+}
+
+
+
+


+ +
Copyright © 2007 +TrolltechTrademarks +
TQt 3.3.8
+
+ -- cgit v1.2.1