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

#include <inputstring.h>

Inheritance diagram for InputString:
Input

Public Types

enum  StringMode {
  StringFree =0, StringFile =1, StringDir =2, StringFixed =3,
  StringImage =4
}
 
- Public Types inherited from Input
enum  Kind {
  Bool, Int, String, StrList,
  Obsolete
}
 

Public Slots

void reset ()
 
void setValue (const QString &)
 

Signals

void changed ()
 
void showHelp (Input *)
 

Public Member Functions

 InputString (QGridLayout *layout, int &row, const QString &id, const QString &s, StringMode m, const QString &docs, const QString &absPath=QString())
 
 ~InputString ()
 
void addValue (QString s)
 
void setDefault ()
 
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 browse ()
 
void clear ()
 
void help ()
 

Private Member Functions

void updateDefault ()
 

Private Attributes

QLabel * m_lab
 
QLineEdit * m_le
 
QLabel * m_im
 
QToolBar * m_br
 
QComboBox * m_com
 
QString m_str
 
QString m_default
 
StringMode m_sm
 
QStringList m_values
 
int m_index
 
QVariant m_value
 
QString m_docs
 
QString m_id
 
bool m_absPath
 
QString m_tdocs
 

Detailed Description

Definition at line 30 of file inputstring.h.

Member Enumeration Documentation

Enumerator
StringFree 
StringFile 
StringDir 
StringFixed 
StringImage 

Definition at line 35 of file inputstring.h.

Constructor & Destructor Documentation

InputString::InputString ( QGridLayout *  layout,
int &  row,
const QString id,
const QString s,
StringMode  m,
const QString docs,
const QString absPath = QString() 
)

Definition at line 39 of file inputstring.cpp.

43  : m_default(s), m_sm(m), m_index(0), m_docs(docs), m_id(id),
44  m_absPath(absPath==QString::fromLatin1("1"))
45 {
46  m_lab = new HelpLabel(id);
47  if (m==StringFixed)
48  {
49  layout->addWidget( m_lab, row, 0 );
50  m_com = new NoWheelComboBox;
51  layout->addWidget( m_com, row, 1, 1, 3, Qt::AlignLeft );
52  m_le=0;
53  m_br=0;
54  m_im=0;
55  row++;
56  }
57  else
58  {
59  layout->addWidget( m_lab, row, 0 );
60  m_le = new QLineEdit;
61  m_le->setText( s );
62  m_im = 0;
63  //layout->setColumnMinimumWidth(2,150);
64  if (m==StringFile || m==StringDir || m==StringImage)
65  {
66  layout->addWidget( m_le, row, 1 );
67  m_br = new QToolBar;
68  m_br->setIconSize(QSize(24,24));
69  if (m==StringFile || m==StringImage)
70  {
71  QAction *file = m_br->addAction(QIcon(QString::fromLatin1(":/images/file.png")),QString(),this,SLOT(browse()));
72  file->setToolTip(tr("Browse to a file"));
73  layout->addWidget( m_br,row,2 );
74  if (m==StringImage)
75  {
76  m_im = new QLabel;
77  m_im->setMinimumSize(1,55);
78  m_im->setAlignment(Qt::AlignLeft|Qt::AlignTop);
79  row++;
80  layout->addWidget( m_im,row,1 );
81  }
82  }
83  else
84  {
85  QAction *dir = m_br->addAction(QIcon(QString::fromLatin1(":/images/folder.png")),QString(),this,SLOT(browse()));
86  dir->setToolTip(tr("Browse to a folder"));
87  layout->addWidget( m_br,row,2 );
88  }
89  }
90  else
91  {
92  layout->addWidget( m_le, row, 1, 1, 2 );
93  m_br=0;
94  m_im=0;
95  }
96  m_com=0;
97  row++;
98  }
99 
100  if (m_le) connect( m_le, SIGNAL(textChanged(const QString&)),
101  this, SLOT(setValue(const QString&)) );
102  if (m_com) connect( m_com, SIGNAL(activated(const QString &)),
103  this, SLOT(setValue(const QString &)) );
104  m_str = s+QChar::fromLatin1('!'); // force update
105  setValue(s);
106  connect( m_lab, SIGNAL(enter()), SLOT(help()) );
107  connect( m_lab, SIGNAL(reset()), SLOT(reset()) );
108 }
void setValue(const QString &)
QString m_docs
Definition: inputstring.h:90
QString m_str
Definition: inputstring.h:84
QLineEdit * m_le
Definition: inputstring.h:80
QToolBar * m_br
Definition: inputstring.h:82
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
def connect(nxgraph, k1, k2, p1=0, p2=0, kwds)
Definition: graph.py:30
QLabel * m_im
Definition: inputstring.h:81
QString m_id
Definition: inputstring.h:91
QString m_default
Definition: inputstring.h:85
bool m_absPath
Definition: inputstring.h:92
QComboBox * m_com
Definition: inputstring.h:83
StringMode m_sm
Definition: inputstring.h:86
QLabel * m_lab
Definition: inputstring.h:79
InputString::~InputString ( )

Definition at line 116 of file inputstring.cpp.

117 {
118 }

Member Function Documentation

void InputString::addDependency ( Input )
inlinevirtual

Implements Input.

Definition at line 58 of file inputstring.h.

58 { Q_ASSERT(false); }
void InputString::addValue ( QString  s)

Definition at line 221 of file inputstring.cpp.

222 {
223  if (m_sm==StringFixed)
224  {
225  m_values.append(s);
226  m_com->addItem(s);
227  }
228 }
Iterator append(const T &x)
Definition: qvaluelist.h:372
QComboBox * m_com
Definition: inputstring.h:83
StringMode m_sm
Definition: inputstring.h:86
QStringList m_values
Definition: inputstring.h:87
void InputString::browse ( )
privateslot

Definition at line 183 of file inputstring.cpp.

184 {
185  QString path = QFileInfo(MainWindow::instance().configFileName()).path();
186  if (m_sm==StringFile || m_sm==StringImage)
187  {
188  QString fileName = QFileDialog::getOpenFileName(&MainWindow::instance(),
189  tr("Select file"),path);
190  if (!fileName.isNull())
191  {
192  QDir dir(path);
193  if (!MainWindow::instance().configFileName().isEmpty() && dir.exists())
194  {
195  fileName = m_absPath ? fileName : dir.relativeFilePath(fileName);
196  }
197  setValue(fileName);
198  }
199  }
200  else // sm==StringDir
201  {
202  QString dirName = QFileDialog::getExistingDirectory(&MainWindow::instance(),
203  tr("Select directory"),path);
204  if (!dirName.isNull())
205  {
206  QDir dir(path);
207  if (!MainWindow::instance().configFileName().isEmpty() && dir.exists())
208  {
209  dirName = m_absPath ? dirName : dir.relativeFilePath(dirName);
210  }
211  setValue(dirName);
212  }
213  }
214 }
Traverses directory structures and contents in a platform-independent way.
Definition: qdir.h:52
void setValue(const QString &)
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
bool m_absPath
Definition: inputstring.h:92
StringMode m_sm
Definition: inputstring.h:86
bool isNull() const
Definition: qstring.h:379
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:51
static MainWindow & instance()
Definition: doxywizard.cpp:34
void InputString::changed ( )
signal
void InputString::clear ( )
privateslot

Definition at line 216 of file inputstring.cpp.

217 {
218  setValue(QString());
219 }
void setValue(const QString &)
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QString InputString::docs ( ) const
inlinevirtual

Implements Input.

Definition at line 55 of file inputstring.h.

55 { return m_docs; }
QString m_docs
Definition: inputstring.h:90
void InputString::help ( )
privateslot

Definition at line 110 of file inputstring.cpp.

111 {
112  showHelp(this);
113 }
void showHelp(Input *)
QString InputString::id ( ) const
inlinevirtual

Implements Input.

Definition at line 56 of file inputstring.h.

56 { return m_id; }
QString m_id
Definition: inputstring.h:91
Kind InputString::kind ( ) const
inlinevirtual

Implements Input.

Definition at line 54 of file inputstring.h.

54 { return String; }
void InputString::reset ( )
slot

Definition at line 247 of file inputstring.cpp.

248 {
250  setDefault();
251 }
void setValue(const QString &)
QString m_default
Definition: inputstring.h:85
void setDefault()
void InputString::setDefault ( )

Definition at line 230 of file inputstring.cpp.

231 {
232  int index = m_values.indexOf(m_str);
233  if (index!=-1 && m_com) m_com->setCurrentIndex(index);
234 }
QString m_str
Definition: inputstring.h:84
QComboBox * m_com
Definition: inputstring.h:83
QStringList m_values
Definition: inputstring.h:87
void InputString::setEnabled ( bool  state)
virtual

Implements Input.

Definition at line 173 of file inputstring.cpp.

174 {
175  m_lab->setEnabled(state);
176  if (m_le) m_le->setEnabled(state);
177  if (m_im) m_im->setEnabled(state);
178  if (m_br) m_br->setEnabled(state);
179  if (m_com) m_com->setEnabled(state);
180  updateDefault();
181 }
void updateDefault()
QLineEdit * m_le
Definition: inputstring.h:80
QToolBar * m_br
Definition: inputstring.h:82
QLabel * m_im
Definition: inputstring.h:81
QComboBox * m_com
Definition: inputstring.h:83
QLabel * m_lab
Definition: inputstring.h:79
void InputString::setTemplateDocs ( const QString docs)
inlinevirtual

Implements Input.

Definition at line 62 of file inputstring.h.

62 { m_tdocs = docs; }
QString m_tdocs
Definition: inputstring.h:93
QString docs() const
Definition: inputstring.h:55
void InputString::setValue ( const QString s)
slot

Definition at line 121 of file inputstring.cpp.

122 {
123  if (m_str!=s)
124  {
125  m_str = s;
126  m_value = m_str;
127  updateDefault();
128  }
129 }
void updateDefault()
QString m_str
Definition: inputstring.h:84
QVariant m_value
Definition: inputstring.h:89
static QCString * s
Definition: config.cpp:1042
void InputString::showHelp ( Input )
signal
QString InputString::templateDocs ( ) const
inlinevirtual

Implements Input.

Definition at line 57 of file inputstring.h.

57 { return m_tdocs; }
QString m_tdocs
Definition: inputstring.h:93
void InputString::update ( )
virtual

Implements Input.

Definition at line 241 of file inputstring.cpp.

242 {
243  setValue(m_value.toString().trimmed());
244  setDefault();
245 }
void setValue(const QString &)
QVariant m_value
Definition: inputstring.h:89
void setDefault()
void InputString::updateDefault ( )
private

Definition at line 130 of file inputstring.cpp.

131 {
132  {
133  if (m_str==m_default || !m_lab->isEnabled())
134  {
135  m_lab->setText(QString::fromLatin1("<qt>")+m_id+QString::fromLatin1("</qt"));
136  }
137  else
138  {
139  m_lab->setText(QString::fromLatin1("<qt><font color='red'>")+m_id+QString::fromLatin1("</font></qt>"));
140  }
141  if (m_im)
142  {
143  if (m_str.isEmpty())
144  {
145  m_im->setText(tr("No Project logo selected."));
146  }
147  else
148  {
149  QFile Fout(m_str);
150  if(!Fout.exists())
151  {
152  m_im->setText(tr("Sorry, cannot find file(")+m_str+QString::fromLatin1(");"));
153  }
154  else
155  {
156  QPixmap pm(m_str);
157  if (!pm.isNull())
158  {
159  m_im->setPixmap(pm.scaledToHeight(55,Qt::SmoothTransformation));
160  }
161  else
162  {
163  m_im->setText(tr("Sorry, no preview available (")+m_str+QString::fromLatin1(");"));
164  }
165  }
166  }
167  }
168  if (m_le && m_le->text()!=m_str) m_le->setText( m_str );
169  emit changed();
170  }
171 }
bool isEmpty() const
Definition: qstring.h:682
void changed()
QString m_str
Definition: inputstring.h:84
QLineEdit * m_le
Definition: inputstring.h:80
static QString fromLatin1(const char *, int len=-1)
Definition: qstring.cpp:14539
QLabel * m_im
Definition: inputstring.h:81
QString m_id
Definition: inputstring.h:91
QString m_default
Definition: inputstring.h:85
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
QLabel * m_lab
Definition: inputstring.h:79
void InputString::updateDependencies ( )
inlinevirtual

Implements Input.

Definition at line 60 of file inputstring.h.

60 {}
QVariant & InputString::value ( )
virtual

Implements Input.

Definition at line 236 of file inputstring.cpp.

237 {
238  return m_value;
239 }
QVariant m_value
Definition: inputstring.h:89
void InputString::writeValue ( QTextStream t,
QTextCodec codec 
)
virtual

Implements Input.

Definition at line 253 of file inputstring.cpp.

254 {
255  writeStringValue(t,codec,m_str);
256 }
QString m_str
Definition: inputstring.h:84
void writeStringValue(QTextStream &t, QTextCodec *codec, const QString &s)

Member Data Documentation

bool InputString::m_absPath
private

Definition at line 92 of file inputstring.h.

QToolBar* InputString::m_br
private

Definition at line 82 of file inputstring.h.

QComboBox* InputString::m_com
private

Definition at line 83 of file inputstring.h.

QString InputString::m_default
private

Definition at line 85 of file inputstring.h.

QString InputString::m_docs
private

Definition at line 90 of file inputstring.h.

QString InputString::m_id
private

Definition at line 91 of file inputstring.h.

QLabel* InputString::m_im
private

Definition at line 81 of file inputstring.h.

int InputString::m_index
private

Definition at line 88 of file inputstring.h.

QLabel* InputString::m_lab
private

Definition at line 79 of file inputstring.h.

QLineEdit* InputString::m_le
private

Definition at line 80 of file inputstring.h.

StringMode InputString::m_sm
private

Definition at line 86 of file inputstring.h.

QString InputString::m_str
private

Definition at line 84 of file inputstring.h.

QString InputString::m_tdocs
private

Definition at line 93 of file inputstring.h.

QVariant InputString::m_value
private

Definition at line 89 of file inputstring.h.

QStringList InputString::m_values
private

Definition at line 87 of file inputstring.h.


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