Changeset 12658 for trunk/FACT++
- Timestamp:
- 11/27/11 18:36:07 (13 years ago)
- Location:
- trunk/FACT++/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/gui/FactGui.h
r12656 r12658 8 8 9 9 #include <boost/bind.hpp> 10 #include <boost/regex.hpp> 10 11 11 12 #include <QTimer> 13 #include <QtSql/QSqlError> 14 #include <QtSql/QSqlTableModel> 12 15 #include <QStandardItemModel> 13 16 … … 4189 4192 4190 4193 // -------------------------------------------------------------------------- 4194 4195 fCommentsWidget->setEnabled(false); 4196 4197 static const boost::regex expr("(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))"); 4198 4199 const string database = conf.Get<string>("CommentDB"); 4200 4201 if (!database.empty()) 4202 { 4203 boost::smatch what; 4204 if (!boost::regex_match(database, what, expr, boost::match_extra)) 4205 throw runtime_error("Couldn't parse '"+database+"'."); 4206 4207 if (what.size()!=10) 4208 throw runtime_error("Error parsing '"+database+"'."); 4209 4210 const string user = what[2]; 4211 const string passwd = what[4]; 4212 const string server = what[5]; 4213 const string db = what[9]; 4214 const int port = atoi(string(what[7]).c_str()); 4215 4216 QSqlDatabase qdb = QSqlDatabase::addDatabase("QMYSQL"); 4217 qdb.setHostName(server.c_str()); 4218 qdb.setDatabaseName(db.c_str()); 4219 qdb.setUserName(user.c_str()); 4220 qdb.setPassword(passwd.c_str()); 4221 qdb.setPort(port); 4222 qdb.setConnectOptions("CLIENT_SSL=1;MYSQL_OPT_RECONNECT=1"); 4223 if (qdb.open()) 4224 { 4225 QSqlTableModel *model = new QSqlTableModel(fTableComments, qdb); 4226 model->setTable("Configuration"); 4227 model->setEditStrategy(QSqlTableModel::OnManualSubmit); 4228 4229 const bool ok2 = model->select(); 4230 4231 if (ok2) 4232 { 4233 fTableComments->setModel(model); 4234 fTableComments->resizeColumnsToContents(); 4235 fTableComments->resizeRowsToContents(); 4236 4237 connect(fCommentSubmit, SIGNAL(clicked()), model, SLOT(submitAll())); 4238 connect(fCommentRevert, SIGNAL(clicked()), model, SLOT(revertAll())); 4239 connect(fCommentUpdateLayout, SIGNAL(clicked()), fTableComments, SLOT(resizeColumnsToContents())); 4240 connect(fCommentUpdateLayout, SIGNAL(clicked()), fTableComments, SLOT(resizeRowsToContents())); 4241 4242 fCommentsWidget->setEnabled(true); 4243 } 4244 else 4245 cout << "\n==> ERROR: Select on table failed.\n" << endl; 4246 } 4247 else 4248 cout << "\n==> ERROR: Connection to database failed:\n " 4249 << qdb.lastError().text().toStdString() << endl << endl; 4250 } 4251 4252 // -------------------------------------------------------------------------- 4191 4253 #ifdef HAVE_ROOT 4192 4254 -
trunk/FACT++/gui/MainWindow.cc
r12528 r12658 108 108 } 109 109 110 void MainWindow::on_fCommentInsertRow_clicked() 111 { 112 if (fTableComments->model()) 113 fTableComments->model()->insertRow(fTableComments->model()->rowCount()); 114 } 115 110 116 void MainWindow::on_fNoutof4Val_valueChanged(int val) 111 117 { -
trunk/FACT++/gui/MainWindow.h
r12528 r12658 46 46 void on_fMcpStopRun_clicked(); 47 47 void on_fMcpReset_clicked(); 48 49 // Comment Sql Table 50 void on_fCommentInsertRow_clicked(); 48 51 49 52 // System status -
trunk/FACT++/gui/fact.cc
r12339 r12658 38 38 ("host", var<string>(""), "Address with which the Dim nameserver can connect to this host (overwites DIM_HOST_NODE environment variable)") 39 39 ("pixel-map-file", var<string>("FACTmap111030.txt"), "Pixel mapping file. Used here to get the default reference voltage.") 40 ("CommentDB", var<string>(""), "") 40 41 ; 41 42
Note:
See TracChangeset
for help on using the changeset viewer.