1 /** @file selectimages.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 "selectimages.hpp"
9 #include "variables.hpp"
15 #include <qpushbutton.h>
19 #include <qwhatsthis.h>
20 #include <qmessagebox.h>
23 * Constructs a selectimageswindow which is a child of 'parent', with the
24 * name 'name' and widget flags set to 'f'
26 * The dialog will by default be modeless, unless you set 'modal' to
27 * TRUE to construct a modal dialog.
29 selectimageswindow::selectimageswindow( QWidget* parent, const char* name, bool modal, WFlags fl )
30 : QDialog( parent, name, modal, fl )
35 setName( "selectimageswindow" );
37 setMinimumSize( QSize( 540, 350 ) );
38 setMaximumSize( QSize( 540, 350 ) );
39 setCaption( tr( "Select Images" ) );
41 okbutton = new QPushButton( this, "okbutton" );
42 okbutton->setGeometry( QRect( 10, 15, 140, 40 ) );
43 okbutton->setText( tr( "Ok" ) );
44 QObject::connect(okbutton,SIGNAL(clicked()),this,SLOT(accept()));
46 selectbutton = new QPushButton( this, "selectbutton" );
47 selectbutton->setGeometry( QRect( 10, 65, 140, 40 ) );
48 selectbutton->setText( tr( "Select All" ) );
49 QObject::connect(selectbutton,SIGNAL(clicked()),this,SLOT(selectAll()));
51 clearselectbutton = new QPushButton( this, "clearselectbutton" );
52 clearselectbutton->setGeometry( QRect( 10, 115, 140, 40 ) );
53 clearselectbutton->setText( tr( "Clear Selected" ) );
54 QObject::connect(clearselectbutton,SIGNAL(clicked()),this,SLOT(clearSelected()));
56 imageslistbox = new QListBox( this, "imageslistbox" );
57 imageslistbox->setSelectionMode(QListBox::Multi);
58 QFont f = QFont("courier",10,25,false);
59 f.setFixedPitch(true);
60 imageslistbox->setFont(f);
61 for(i=0;i<numimages;i++)
62 imageslistbox->insertItem(imagetitles[i]);
63 imageslistbox->setGeometry( QRect( 160, 15, 370, 250 ) );
65 Line6 = new QFrame( this, "Line6" );
66 Line6->setGeometry( QRect( 0, 280, 540, 16 ) );
67 Line6->setFrameStyle( QFrame::HLine | QFrame::Sunken );
69 cancelbutton = new QPushButton( this, "cancelbutton" );
70 cancelbutton->setGeometry( QRect( 300, 300, 100, 40 ) );
71 cancelbutton->setText( tr( "Cancel" ) );
72 QObject::connect(cancelbutton,SIGNAL(clicked()),this,SLOT(reject()));
76 * Destroys the object and frees any allocated resources
78 selectimageswindow::~selectimageswindow()
80 // no need to delete child widgets, Qt does it all for us
83 int* selectimageswindow::getSelectedImages()
85 int i,j,nsi=0,*siarray;
87 for(i=0;i<numimages;i++)
88 if(imageslistbox->isSelected(i))
91 siarray = (int*) malloc((unsigned) (nsi+1)*sizeof(int));
93 QMessageBox::information(this,"SnarkDisplay","Error!\n"
94 "Allocation failure in getSelectedImages()\n");
99 for(i=0;i<numimages;i++)
100 if(imageslistbox->isSelected(i)) {
108 void selectimageswindow::selectAll()
110 imageslistbox->selectAll(true);
113 void selectimageswindow::clearSelected()
115 imageslistbox->selectAll(false);