File: ringdialog.cpp

package info (click to toggle)
xdrawchem 1.0-0.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,820 kB
  • ctags: 2,389
  • sloc: cpp: 17,801; makefile: 263; ansic: 168
file content (64 lines) | stat: -rw-r--r-- 1,712 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <qwidget.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qdialog.h>
#include <qcolor.h>
#include <qfont.h>
#include <qnamespace.h>
#include <qpixmap.h>
#include <qcombobox.h>
#include <qvbox.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qdir.h>
#include <qstringlist.h>
#include <iostream.h>

#include "ringdialog.h"
#include "defs.h"

// defined in main.cpp
extern QString RingDir;

RingDialog::RingDialog(QWidget *parent, QString name):
  QDialog(parent, name, TRUE)
{
  // Init variables which tell which ring was picked
  fn = QString("noring");

  QPixmap pix;
  QLabel *caption;
  QPushButton *dismiss;
  setBackgroundColor(lightGray);
  setCaption( tr("Ring tool") );

  QGridLayout *mygrid = new QGridLayout(this,4,5,5);

  caption = new QLabel(tr("Choose a structure from list:"), this);
  caption->setBackgroundColor(lightGray);
  mygrid->addMultiCellWidget(caption, 0, 0, 0, 4);

  QDir dr(RingDir, "*.cml");
  QStringList dl = dr.entryList();
  filelist = new QComboBox(FALSE, this);
  filelist->insertItem("(pick)");
  for (int cc = 0; cc < dl.count(); cc++)
    filelist->insertItem(dl[cc].left(dl[cc].length() - 4));
  connect(filelist, SIGNAL(activated(int)),
	  this, SLOT(fromComboBox(int)) );
  mygrid->addMultiCellWidget(filelist, 1, 1, 0, 4);
  
  dismiss = new QPushButton(tr("Cancel"), this);
  dismiss->setPalette(QPalette(lightGray));
  connect(dismiss, SIGNAL(clicked()), SLOT(reject()) );
  mygrid->addMultiCellWidget(dismiss, 2, 2, 1, 3);
}

void RingDialog::fromComboBox(int i)
{
  if (filelist->currentText() == "(pick)") return;
  fn = filelist->currentText() + QString(".cml");
  //cout << "File: " << fn << endl;
  accept();
}