Public Types | Public Slots | Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
InputStrList Class Reference

#include <inputstrlist.h>

Inheritance diagram for InputStrList:
Input

Public Types

enum  ListMode { ListString = 0, ListFile = 1, ListDir = 2, ListFileDir = ListFile | ListDir }
 
- Public Types inherited from Input
enum  Kind {
  Bool, Int, String, StrList,
  Obsolete
}
 

Public Slots

void reset ()
 

Signals

void changed ()
 
void showHelp (Input *)
 

Public Member Functions

 InputStrList (QGridLayout *layout, int &row, const QString &id, const QStringList &sl, ListMode v, const QString &docs)
 
void setValue (const QStringList &sl)
 
QVariant & value ()
 
void update ()
 
Kind kind () const
 
QString docs () const
 
QString id () const
 
QString templateDocs () const
 
void addDependency (Input *)
 
void setEnabled (bool)
 
void updateDependencies ()
 
void writeValue (QTextStream &t, QTextCodec *codec)
 
void setTemplateDocs (const QString &docs)
 
- Public Member Functions inherited from Input
virtual ~Input ()
 
virtual void reset ()=0
 

Private Slots

void addString ()
 
void delString ()
 
void updateString ()
 
void selectText (const QString &s)
 
void browseFiles ()
 
void browseDir ()
 
void help ()
 

Private Member Functions

void updateDefault ()
 

Private Attributes

QLabel * m_lab
 
QLineEdit * m_le
 
QAction * m_add
 
QAction * m_del
 
QAction * m_upd
 
QAction * m_brFile
 
QAction * m_brDir
 
QListWidget * m_lb
 
QStringList m_default
 
QStringList m_strList
 
QVariant m_value
 
QString m_docs
 
QString m_id
 
QString m_tdocs
 

Detailed Description

Definition at line 31 of file inputstrlist.h.

Member Enumeration Documentation

Enumerator
ListString 
ListFile 
ListDir 
ListFileDir 

Definition at line 36 of file inputstrlist.h.

Constructor & Destructor Documentation

InputStrList::InputStrList ( QGridLayout *  layout,
int &  row,
const QString id,
const QStringList sl,
ListMode  v,
const QString docs 
)

Definition at line 29 of file inputstrlist.cpp.

33  : m_default(sl), m_strList(sl), m_docs(docs), m_id(id)
34 {
35  m_lab = new HelpLabel( id );
36 
37  m_le = new QLineEdit;
38  m_le->clear();
39 
40  QToolBar *toolBar = new QToolBar;
41  toolBar->setIconSize(QSize(24,24));
42  m_add = toolBar->addAction(QIcon(QString::fromLatin1(":/images/add.png")),QString(),
43  this,SLOT(addString()));
44  m_add->setToolTip(tr("Add item"));
45  m_del = toolBar->addAction(QIcon(QString::fromLatin1(":/images/del.png")),QString(),
46  this,SLOT(delString()));
47  m_del->setToolTip(tr("Delete selected item"));
48  m_upd = toolBar->addAction(QIcon(QString::fromLatin1(":/images/refresh.png")),QString(),
49  this,SLOT(updateString()));
50  m_upd->setToolTip(tr("Update selected item"));
51 
52  m_lb = new QListWidget;
53  //m_lb->setMinimumSize(400,100);
54  foreach (QString s, m_strList) m_lb->addItem(s);
55 
56  m_brFile=0;
57  m_brDir=0;
58  if (lm!=ListString)
59  {
60  if (lm&ListFile)
61  {
62  m_brFile = toolBar->addAction(QIcon(QString::fromLatin1(":/images/file.png")),QString(),
63  this,SLOT(browseFiles()));
64  m_brFile->setToolTip(tr("Browse to a file"));
65  }
66  if (lm&ListDir)
67  {
68  m_brDir = toolBar->addAction(QIcon(QString::fromLatin1(":/images/folder.png")),QString(),
69  this,SLOT(browseDir()));
70  m_brDir->setToolTip(tr("Browse to a folder"));
71  }
72  }
73  QHBoxLayout *rowLayout = new QHBoxLayout;
74  rowLayout->addWidget( m_le );
75  rowLayout->addWidget( toolBar );
76  layout->addWidget( m_lab, row,0 );
77  layout->addLayout( rowLayout, row,1,1,2 );
78  layout->addWidget( m_lb, row+1,1,1,2 );
79  row+=2;
80 
82 
83  connect(m_le, SIGNAL(returnPressed()),
84  this, SLOT(addString()) );
85  connect(m_lb, SIGNAL(currentTextChanged(const QString &)),
86  this, SLOT(selectText(const QString &)));
87  connect( m_lab, SIGNAL(enter()), SLOT(help()) );
88  connect( m_lab, SIGNAL(reset()), SLOT(reset()) );
89 }
QLabel * m_lab
Definition: inputstrlist.h:77
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QAction * m_add
Definition: inputstrlist.h:79
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
def connect(nxgraph, k1, k2, p1=0, p2=0, kwds)
Definition: graph.py:30
void browseFiles()
void addString()
QString m_docs
Definition: inputstrlist.h:88
QLineEdit * m_le
Definition: inputstrlist.h:78
QAction * m_brFile
Definition: inputstrlist.h:82
QVariant m_value
Definition: inputstrlist.h:87
QStringList m_strList
Definition: inputstrlist.h:86
QAction * m_brDir
Definition: inputstrlist.h:83
QStringList m_default
Definition: inputstrlist.h:85
QString m_id
Definition: inputstrlist.h:89
QAction * m_upd
Definition: inputstrlist.h:81
void selectText(const QString &s)
QListWidget * m_lb
Definition: inputstrlist.h:84
QAction * m_del
Definition: inputstrlist.h:80
void updateString()
static QCString * s
Definition: config.cpp:1042

Member Function Documentation

void InputStrList::addDependency ( Input )
inlinevirtual

Implements Input.

Definition at line 53 of file inputstrlist.h.

53 { Q_ASSERT(false); }
void InputStrList::addString ( )
privateslot

Definition at line 97 of file inputstrlist.cpp.

98 {
99  if (!m_le->text().isEmpty())
100  {
101  m_lb->addItem(m_le->text());
102  m_strList.append(m_le->text());
103  m_value = m_strList;
104  updateDefault();
105  emit changed();
106  m_le->clear();
107  }
108 }
Iterator append(const T &x)
Definition: qvaluelist.h:372
void changed()
QLineEdit * m_le
Definition: inputstrlist.h:78
QVariant m_value
Definition: inputstrlist.h:87
QStringList m_strList
Definition: inputstrlist.h:86
void updateDefault()
QListWidget * m_lb
Definition: inputstrlist.h:84
void InputStrList::browseDir ( )
privateslot

Definition at line 184 of file inputstrlist.cpp.

185 {
186  QString path = QFileInfo(MainWindow::instance().configFileName()).path();
187  QString dirName = QFileDialog::getExistingDirectory();
188 
189  if (!dirName.isNull())
190  {
191  QDir dir(path);
192  if (!MainWindow::instance().configFileName().isEmpty() && dir.exists())
193  {
194  dirName = dir.relativeFilePath(dirName);
195  }
196  if (dirName.isEmpty())
197  {
198  dirName=QString::fromLatin1(".");
199  }
200  m_lb->addItem(dirName);
201  m_strList.append(dirName);
202  m_value = m_strList;
203  updateDefault();
204  emit changed();
205  m_le->setText(dirName);
206  }
207 }
Traverses directory structures and contents in a platform-independent way.
Definition: qdir.h:52
bool isEmpty() const
Definition: qstring.h:682
Iterator append(const T &x)
Definition: qvaluelist.h:372
void changed()
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
string dir
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
QLineEdit * m_le
Definition: inputstrlist.h:78
QVariant m_value
Definition: inputstrlist.h:87
QStringList m_strList
Definition: inputstrlist.h:86
void updateDefault()
bool isNull() const
Definition: qstring.h:379
QListWidget * m_lb
Definition: inputstrlist.h:84
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:51
static MainWindow & instance()
Definition: doxywizard.cpp:34
void InputStrList::browseFiles ( )
privateslot

Definition at line 154 of file inputstrlist.cpp.

155 {
156  QString path = QFileInfo(MainWindow::instance().configFileName()).path();
157  QStringList fileNames = QFileDialog::getOpenFileNames();
158 
159  if (!fileNames.isEmpty())
160  {
162  for ( it= fileNames.begin(); it != fileNames.end(); ++it )
163  {
165  QDir dir(path);
166  if (!MainWindow::instance().configFileName().isEmpty() && dir.exists())
167  {
168  fileName = dir.relativeFilePath(*it);
169  }
170  if (fileName.isEmpty())
171  {
172  fileName = *it;
173  }
174  m_lb->addItem(fileName);
175  m_strList.append(fileName);
176  m_value = m_strList;
177  updateDefault();
178  emit changed();
179  }
180  m_le->setText(m_strList[0]);
181  }
182 }
Traverses directory structures and contents in a platform-independent way.
Definition: qdir.h:52
bool isEmpty() const
Definition: qstring.h:682
Iterator append(const T &x)
Definition: qvaluelist.h:372
void changed()
Iterator end()
Definition: qvaluelist.h:363
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
string dir
fileName
Definition: dumpTree.py:9
QLineEdit * m_le
Definition: inputstrlist.h:78
A list of strings.
Definition: qstringlist.h:51
QVariant m_value
Definition: inputstrlist.h:87
QStringList m_strList
Definition: inputstrlist.h:86
void updateDefault()
Iterator begin()
Definition: qvaluelist.h:361
bool isEmpty() const
Definition: qvaluelist.h:368
QListWidget * m_lb
Definition: inputstrlist.h:84
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:51
static MainWindow & instance()
Definition: doxywizard.cpp:34
void InputStrList::changed ( )
signal
void InputStrList::delString ( )
privateslot

Definition at line 110 of file inputstrlist.cpp.

111 {
112  if (m_lb->currentRow()!=-1)
113  {
114  int itemIndex = m_lb->currentRow();
115  delete m_lb->currentItem();
116  m_strList.removeAt(itemIndex);
117  m_value = m_strList;
118  updateDefault();
119  emit changed();
120  }
121 }
void changed()
QVariant m_value
Definition: inputstrlist.h:87
QStringList m_strList
Definition: inputstrlist.h:86
void updateDefault()
QListWidget * m_lb
Definition: inputstrlist.h:84
QString InputStrList::docs ( ) const
inlinevirtual

Implements Input.

Definition at line 50 of file inputstrlist.h.

50 { return m_docs; }
QString m_docs
Definition: inputstrlist.h:88
void InputStrList::help ( )
privateslot

Definition at line 91 of file inputstrlist.cpp.

92 {
93  showHelp(this);
94 }
void showHelp(Input *)
QString InputStrList::id ( ) const
inlinevirtual

Implements Input.

Definition at line 51 of file inputstrlist.h.

51 { return m_id; }
QString m_id
Definition: inputstrlist.h:89
Kind InputStrList::kind ( ) const
inlinevirtual

Implements Input.

Definition at line 49 of file inputstrlist.h.

49 { return StrList; }
void InputStrList::reset ( )
slot

Definition at line 243 of file inputstrlist.cpp.

244 {
246 }
void setValue(const QStringList &sl)
QStringList m_default
Definition: inputstrlist.h:85
void InputStrList::selectText ( const QString s)
privateslot

Definition at line 136 of file inputstrlist.cpp.

137 {
138  m_le->setText(s);
139 }
QLineEdit * m_le
Definition: inputstrlist.h:78
void InputStrList::setEnabled ( bool  state)
virtual

Implements Input.

Definition at line 141 of file inputstrlist.cpp.

142 {
143  m_lab->setEnabled(state);
144  m_le->setEnabled(state);
145  m_add->setEnabled(state);
146  m_del->setEnabled(state);
147  m_upd->setEnabled(state);
148  m_lb->setEnabled(state);
149  if (m_brFile) m_brFile->setEnabled(state);
150  if (m_brDir) m_brDir->setEnabled(state);
151  updateDefault();
152 }
QLabel * m_lab
Definition: inputstrlist.h:77
QAction * m_add
Definition: inputstrlist.h:79
QLineEdit * m_le
Definition: inputstrlist.h:78
QAction * m_brFile
Definition: inputstrlist.h:82
void updateDefault()
QAction * m_brDir
Definition: inputstrlist.h:83
QAction * m_upd
Definition: inputstrlist.h:81
QListWidget * m_lb
Definition: inputstrlist.h:84
QAction * m_del
Definition: inputstrlist.h:80
void InputStrList::setTemplateDocs ( const QString docs)
inlinevirtual

Implements Input.

Definition at line 57 of file inputstrlist.h.

57 { m_tdocs = docs; }
QString m_tdocs
Definition: inputstrlist.h:90
QString docs() const
Definition: inputstrlist.h:50
void InputStrList::setValue ( const QStringList sl)

Definition at line 209 of file inputstrlist.cpp.

210 {
211  m_le->clear();
212  m_lb->clear();
213  m_strList = sl;
214  for (int i=0;i<m_strList.size();i++)
215  {
216  m_lb->addItem(m_strList[i].trimmed());
217  }
218  updateDefault();
219 }
QLineEdit * m_le
Definition: inputstrlist.h:78
QStringList m_strList
Definition: inputstrlist.h:86
void updateDefault()
QListWidget * m_lb
Definition: inputstrlist.h:84
void InputStrList::showHelp ( Input )
signal
QString InputStrList::templateDocs ( ) const
inlinevirtual

Implements Input.

Definition at line 52 of file inputstrlist.h.

52 { return m_tdocs; }
QString m_tdocs
Definition: inputstrlist.h:90
void InputStrList::update ( )
virtual

Implements Input.

Definition at line 226 of file inputstrlist.cpp.

227 {
228  setValue(m_value.toStringList());
229 }
void setValue(const QStringList &sl)
QVariant m_value
Definition: inputstrlist.h:87
void InputStrList::updateDefault ( )
private

Definition at line 231 of file inputstrlist.cpp.

232 {
233  if (m_strList==m_default || !m_lab->isEnabled())
234  {
235  m_lab->setText(QString::fromLatin1("<qt>")+m_id+QString::fromLatin1("</qt"));
236  }
237  else
238  {
239  m_lab->setText(QString::fromLatin1("<qt><font color='red'>")+m_id+QString::fromLatin1("</font></qt>"));
240  }
241 }
QLabel * m_lab
Definition: inputstrlist.h:77
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
QStringList m_strList
Definition: inputstrlist.h:86
QStringList m_default
Definition: inputstrlist.h:85
QString m_id
Definition: inputstrlist.h:89
void InputStrList::updateDependencies ( )
inlinevirtual

Implements Input.

Definition at line 55 of file inputstrlist.h.

55 {}
void InputStrList::updateString ( )
privateslot

Definition at line 123 of file inputstrlist.cpp.

124 {
125  if (m_lb->currentRow()!=-1 && !m_le->text().isEmpty())
126  {
127  m_lb->currentItem()->setText(m_le->text());
128  m_strList.insert(m_lb->currentRow(),m_le->text());
129  m_strList.removeAt(m_lb->currentRow()+1);
130  m_value = m_strList;
131  updateDefault();
132  emit changed();
133  }
134 }
Iterator insert(Iterator it, const T &x)
Definition: qvaluelist.h:370
void changed()
QLineEdit * m_le
Definition: inputstrlist.h:78
QVariant m_value
Definition: inputstrlist.h:87
QStringList m_strList
Definition: inputstrlist.h:86
void updateDefault()
QListWidget * m_lb
Definition: inputstrlist.h:84
QVariant & InputStrList::value ( )
virtual

Implements Input.

Definition at line 221 of file inputstrlist.cpp.

222 {
223  return m_value;
224 }
QVariant m_value
Definition: inputstrlist.h:87
void InputStrList::writeValue ( QTextStream t,
QTextCodec codec 
)
virtual

Implements Input.

Definition at line 248 of file inputstrlist.cpp.

249 {
250  bool first=true;
251  foreach (QString s, m_strList)
252  {
253  if (!first)
254  {
255  t << " \\" << endl;
256  t << " ";
257  }
258  first=false;
259  writeStringValue(t,codec,s);
260  }
261 }
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QStringList m_strList
Definition: inputstrlist.h:86
void writeStringValue(QTextStream &t, QTextCodec *codec, const QString &s)
static QCString * s
Definition: config.cpp:1042
QTextStream & endl(QTextStream &s)

Member Data Documentation

QAction* InputStrList::m_add
private

Definition at line 79 of file inputstrlist.h.

QAction* InputStrList::m_brDir
private

Definition at line 83 of file inputstrlist.h.

QAction* InputStrList::m_brFile
private

Definition at line 82 of file inputstrlist.h.

QStringList InputStrList::m_default
private

Definition at line 85 of file inputstrlist.h.

QAction* InputStrList::m_del
private

Definition at line 80 of file inputstrlist.h.

QString InputStrList::m_docs
private

Definition at line 88 of file inputstrlist.h.

QString InputStrList::m_id
private

Definition at line 89 of file inputstrlist.h.

QLabel* InputStrList::m_lab
private

Definition at line 77 of file inputstrlist.h.

QListWidget* InputStrList::m_lb
private

Definition at line 84 of file inputstrlist.h.

QLineEdit* InputStrList::m_le
private

Definition at line 78 of file inputstrlist.h.

QStringList InputStrList::m_strList
private

Definition at line 86 of file inputstrlist.h.

QString InputStrList::m_tdocs
private

Definition at line 90 of file inputstrlist.h.

QAction* InputStrList::m_upd
private

Definition at line 81 of file inputstrlist.h.

QVariant InputStrList::m_value
private

Definition at line 87 of file inputstrlist.h.


The documentation for this class was generated from the following files: