1 /** @file openimages.cpp
2 @package snark14Display
3 @author Bruno M. Carvalho and Deniz Sarioz
4 licensed under (open-source) QPL v1.0
5 which accompanies this distribution in the file QPL
8 #include "variables.hpp"
9 #include "openimages.hpp"
10 #include "displaywindow.hpp"
11 #include "SnarkDisplay.hpp"
14 #include <qapplication.h>
17 #include <qpushbutton.h>
21 #include <qwhatsthis.h>
24 // extern displaywindow **displaywindowset;
27 * Constructs a openimageswindow which is a child of 'parent', with the
28 * name 'name' and widget flags set to 'f'
30 * The dialog will by default be modeless, unless you set 'modal' to
31 * TRUE to construct a modal dialog.
33 openimageswindow::openimageswindow( displaywindow** displaywindowset_in, QWidget* parent, const char* name, bool modal, WFlags fl , int x , int y )
34 // : QDialog( parent, name, modal, fl )
35 : QWidget( parent, name, fl )
38 displaywindowset = displaywindowset_in;
40 setName( "openimageswindow" );
42 setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sizePolicy().hasHeightForWidth() ) );
43 setMinimumSize( QSize( 540, 350 ) );
44 setMaximumSize( QSize( 540, 350 ) );
45 setCaption( tr( "Open Images" ) );
52 openbutton = new QPushButton( this, "openbutton" );
53 openbutton->setGeometry( QRect( 10, 15, 140, 40 ) );
54 openbutton->setText( tr( "Open" ) );
56 QObject::connect(openbutton,SIGNAL(clicked()) ,this, SLOT(openImages()));
58 selectbutton = new QPushButton( this, "selectbutton" );
59 selectbutton->setGeometry( QRect( 10, 65, 140, 40 ) );
60 selectbutton->setText( tr( "Select All" ) );
61 QObject::connect(selectbutton,SIGNAL(clicked()),this,SLOT(selectAll()));
62 // QObject::connect(openbutton,SIGNAL(clicked()) ,parent, SLOT(signalAllDifference(bool)));
65 clearselectbutton = new QPushButton( this, "clearselectbutton" );
66 clearselectbutton->setGeometry( QRect( 10, 115, 140, 40 ) );
67 clearselectbutton->setText( tr( "Clear Selected" ) );
68 QObject::connect(clearselectbutton,SIGNAL(clicked()),this,SLOT(clearSelected()));
70 imageslistbox = new QListBox( this, "imageslistbox" );
71 imageslistbox->setSelectionMode(QListBox::Multi);
72 QFont f = QFont("courier",10,25,false);
73 f.setFixedPitch(true);
74 imageslistbox->setFont(f);
75 for(int i=0;i<numimages;i++)
76 imageslistbox->insertItem(imagetitles[i]);
77 imageslistbox->setGeometry( QRect( 160, 15, 370, 250 ) );
79 Line6 = new QFrame( this, "Line6" );
80 Line6->setGeometry( QRect( 0, 280, 540, 16 ) );
81 Line6->setFrameStyle( QFrame::HLine | QFrame::Sunken );
83 closebutton = new QPushButton( this, "closebutton" );
84 closebutton->setGeometry( QRect( 380, 300, 100, 40 ) );
85 closebutton->setText( tr( "Close" ) );
86 // QObject::connect(closebutton,SIGNAL(clicked()),this,SLOT(reject()));
87 QObject::connect(closebutton,SIGNAL(clicked()),this,SLOT(close()));
92 * Destroys the object and frees any allocated resources
94 openimageswindow::~openimageswindow()
96 // no need to delete child widgets, Qt does it all for us
100 void openimageswindow::openImages()
102 // std::cerr << "++openimageswindow::openImages()" << std::endl;
108 for(i=0;i<numimages;i++) {
109 // std::cerr << "in openimages() for loop, i=" << i << std::endl;
110 // std::cerr << "displaywindowset[i]=" << (displaywindowset[i])
111 // << " active: " << (displaywindowactive[i] ? "yes" : "no")
113 // the new way--should only happen in the first pass of the same recfil
114 // if(!displaywindowset[i]) {
115 // displaywindowset[i]=new displaywindow(0,"",false,0,dataformat,i,x,y);
117 if((imageslistbox->isSelected(i)) && (!displaywindowactive[i])) {
118 // std::cerr << "SHOWING for i=" << i << std::endl;
119 // fixed HUGE bug while trying to fix bug #119 (which was a while ago)
120 // displaywindow* nw=new displaywindow(desk,"",false,0,dataformat,i,x,y);
124 if(y>(maxSizey-630)) {
127 if(x>(maxSizex-50)) {
130 if(!displaywindowset[i]) {
131 displaywindowset[i]=new displaywindow(0,"",false,0,dataformat,i,x,y);
133 displaywindowactive[i]=true;
134 displaywindowset[i]->show();
135 displaywindowset[i]->updateZoom(); // trick to get right size scroll pane
138 // std::cerr << "--openimageswindow::openImages()" << std::endl;
139 } // --openimageswindow::openImages()
142 void openimageswindow::setImagesNames()
146 imageslistbox->clear();
147 for(i=0;i<numimages;i++)
148 imageslistbox->insertItem(imagetitles[i]);
152 void openimageswindow::selectAll()
154 imageslistbox->selectAll(true);
158 void openimageswindow::clearSelected()
160 imageslistbox->selectAll(false);