Index: src/UIElements/QT4/QTDialog.cpp
===================================================================
--- src/UIElements/QT4/QTDialog.cpp	(revision ee62e410040b62b213378576c1c85f0f6526af60)
+++ src/UIElements/QT4/QTDialog.cpp	(revision c96c66b9929d064bdd99474f03b644e0fa4ea88d)
@@ -108,56 +108,78 @@
 }
 
-void QTDialog::queryAtom(const char*, std::string){
+void QTDialog::queryAtom(const char* title, std::string)
+{
+  registerQuery(new AtomQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryAtoms(const char* title, std::string)
+{
+  registerQuery(new AtomsQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryBox(const char* title, std::string){
   // TODO
   ASSERT(false, "Not implemented yet");
 }
 
-void QTDialog::queryAtoms(const char*, std::string){
+
+void QTDialog::queryInt(const char *title,string)
+{
+  registerQuery(new IntQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryInts(const char *title,string)
+{
+  registerQuery(new IntsQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryDouble(const char* title,string)
+{
+  registerQuery(new DoubleQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryDoubles(const char* title,string)
+{
+  registerQuery(new DoublesQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryString(const char* title,string)
+{
+  registerQuery(new StringQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryStrings(const char* title,string)
+{
+  registerQuery(new StringsQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryMolecule(const char *title,string)
+{
+  registerQuery(new MoleculeQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryMolecules(const char *title,string)
+{
   // TODO
   ASSERT(false, "Not implemented yet");
 }
 
-void QTDialog::queryBox(const char*, std::string){
+void QTDialog::queryVector(const char* title, bool check,string)
+{
+  registerQuery(new VectorQTQuery(title,check,inputLayout,this));
+}
+
+void QTDialog::queryVectors(const char* title, bool check,string)
+{
   // TODO
   ASSERT(false, "Not implemented yet");
 }
 
-
-void QTDialog::queryInt(const char *title,string)
-{
-  registerQuery(new IntQTQuery(title,inputLayout,this));
-}
-
-void QTDialog::queryInts(const char *title,string)
-{
-  registerQuery(new IntsQTQuery(title,inputLayout,this));
-}
-
-void QTDialog::queryDouble(const char* title,string)
-{
-  registerQuery(new DoubleQTQuery(title,inputLayout,this));
-}
-
-void QTDialog::queryDoubles(const char* title,string)
-{
-  registerQuery(new DoublesQTQuery(title,inputLayout,this));
-}
-
-void QTDialog::queryString(const char* title,string)
-{
-  registerQuery(new StringQTQuery(title,inputLayout,this));
-}
-
-void QTDialog::queryStrings(const char* title,string)
-{
-  registerQuery(new StringsQTQuery(title,inputLayout,this));
-}
-
-void QTDialog::queryMolecule(const char *title,string)
-{
-  registerQuery(new MoleculeQTQuery(title,inputLayout,this));
-}
-
-void QTDialog::queryMolecules(const char *title,string)
+void QTDialog::queryElement(const char* title, std::string)
+{
+  registerQuery(new ElementQTQuery(title,inputLayout,this));
+}
+
+void QTDialog::queryElements(const char* title, std::string)
 {
   // TODO
@@ -165,26 +187,4 @@
 }
 
-void QTDialog::queryVector(const char* title, bool check,string)
-{
-  registerQuery(new VectorQTQuery(title,check,inputLayout,this));
-}
-
-void QTDialog::queryVectors(const char* title, bool check,string)
-{
-  // TODO
-  ASSERT(false, "Not implemented yet");
-}
-
-void QTDialog::queryElement(const char* title, std::string)
-{
-  registerQuery(new ElementQTQuery(title,inputLayout,this));
-}
-
-void QTDialog::queryElements(const char* title, std::string)
-{
-  // TODO
-  ASSERT(false, "Not implemented yet");
-}
-
 void QTDialog::queryFile(const char* title, std::string)
 {
@@ -193,4 +193,84 @@
 
 /************************** Query Objects *******************************/
+
+QTDialog::AtomQTQuery::AtomQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::AtomQuery(_title),
+    parent(_parent)
+{
+  thisLayout = new QHBoxLayout();
+  titleLabel = new QLabel(QString(getTitle().c_str()));
+  inputBox = new QComboBox();
+  inputBox->insertItem(-1, QString("no atom"));
+  std::vector<atom *> atoms = World::getInstance().getAllAtoms();
+  for (std::vector<atom *>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter)
+    inputBox->insertItem((*iter)->getNr(),QString::fromStdString((*iter)->getName()));
+
+  parent->addLayout(thisLayout);
+  thisLayout->addWidget(titleLabel);
+  thisLayout->addWidget(inputBox);
+
+  pipe = new AtomQTQueryPipe(&tmp,_dialog, inputBox);
+  pipe->update(inputBox->currentIndex());
+  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
+}
+
+QTDialog::AtomQTQuery::~AtomQTQuery()
+{
+  delete pipe;
+}
+
+bool QTDialog::AtomQTQuery::handle() {
+  return true;
+}
+
+
+QTDialog::AtomsQTQuery::AtomsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
+    Dialog::AtomsQuery(_title),
+    parent(_parent)
+{
+  QHBoxLayout * thisHLayout = new QHBoxLayout();
+  QVBoxLayout * thisV1Layout = new QVBoxLayout();
+  QVBoxLayout * thisV2Layout = new QVBoxLayout();
+
+  QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
+  QLabel *inputLabel = new QLabel("Enter to add");
+  QListWidget* inputList = new QListWidget();
+  inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
+  std::vector<atom *> atoms = World::getInstance().getAllAtoms();
+  for (std::vector<atom *>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter)
+    inputBox->insertItem((*iter)->getNr(),QString((*iter)->getNr()));
+
+  QLineEdit* inputBox = new QLineEdit();
+  inputLabel->setBuddy(inputBox);
+  titleLabel->setBuddy(inputList);
+  QPushButton* AddButton = new QPushButton("Add");
+  AddButton->setEnabled(false);
+  QPushButton* RemoveButton = new QPushButton("Remove");
+  RemoveButton->setEnabled(false);
+
+  thisV1Layout->addWidget(titleLabel);
+  thisV1Layout->addWidget(inputList);
+  thisV2Layout->addWidget(inputLabel);
+  thisV2Layout->addWidget(inputBox);
+  thisV2Layout->addWidget(AddButton);
+  thisV2Layout->addWidget(RemoveButton);
+  parent->addLayout(thisHLayout);
+  thisHLayout->addLayout(thisV1Layout);
+  thisHLayout->addLayout(thisV2Layout);
+
+  pipe = new AtomsQTQueryPipe(&tmp,_dialog,inputList);
+  connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
+  connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(add()));
+  connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(remove()));
+}
+
+QTDialog::AtomsQTQuery::~AtomsQTQuery()
+{
+  delete pipe;
+}
+
+bool QTDialog::AtomsQTQuery::handle() {
+  return true;
+}
 
 QTDialog::IntQTQuery::IntQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
@@ -868,8 +948,8 @@
 
 
-AtomsQTQueryPipe::AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
+AtomsQTQueryPipe::AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QListWidget *_theList) :
   content(_content),
   dialog(_dialog),
-  theBox(_theBox)
+  theList(_theList)
 {}
 
@@ -877,11 +957,37 @@
 {}
 
-void AtomsQTQueryPipe::update(int newIndex) {
-  QVariant data = theBox->itemData(newIndex);
-  int idx = data.toInt();
-  atom *Walker = World::getInstance().getAtom(AtomById(idx));
-  if (Walker)
-    (*content).push_back(Walker) ;
-  dialog->update();
+void AtomsQTQueryPipe::update() {
+  // clear target and put all atoms therein
+  (*content).clear();
+  for (std::set<atom *>::iterator iter = currentList.begin(); iter != currentList.end(); ++iter)
+    (*content).push_back(*iter);
+  dialog->update();
+}
+
+void AtomsQTQueryPipe::add() {
+  QList<QListWidgetItem *> items = theList->selectedItems();
+  for (QList<QListWidgetItem *>::iterator iter = items.begin();iter != items.end();++iter) {
+    const int index = (*iter)->text().toInt();
+    atom *Walker = World::getInstance().getAtom(AtomById(index));
+    if (Walker) {
+      (*content).push_back(Walker);
+      currentList.insert(Walker);
+      if (lookup.find(index) != lookup.end())
+        lookup.insert(pair<int, atom*>(index, Walker));
+    }
+  }
+  update();
+}
+
+void AtomsQTQueryPipe::remove() {
+  QList<QListWidgetItem *> items = theList->selectedItems();
+  for (QList<QListWidgetItem *>::iterator iter = items.begin();iter != items.end();++iter) {
+    const int index = (*iter)->text().toInt();
+    atom *Walker = World::getInstance().getAtom(AtomById(index));
+    if (Walker) {
+      currentList.erase(Walker);
+    }
+  }
+  update();
 }
 
