3 #include <QApplication>
27 #define timeFmt QString("hh:mm:ss")
28 #define nowTime() "T="+QDateTime::currentDateTime().toString(timeFmt)
31 int main(
int argc,
char* argv[] )
33 QApplication application( argc, argv );
42 return application.exec();
53 setWindowTitle( tr(
"Manage US DB/Local Data Sets" ) );
55 DbgLv(1) <<
"GUI setup begun";
58 QHBoxLayout* mainLayout =
new QHBoxLayout(
this );
59 QVBoxLayout* leftLayout =
new QVBoxLayout();
60 QVBoxLayout* rghtLayout =
new QVBoxLayout();
61 QGridLayout* dctlLayout =
new QGridLayout();
62 QVBoxLayout* smryLayout =
new QVBoxLayout();
63 QGridLayout* statLayout =
new QGridLayout();
64 QGridLayout* treeLayout =
new QGridLayout();
65 mainLayout->setSpacing ( 2 );
66 mainLayout->setContentsMargins( 2, 2, 2, 2 );
67 leftLayout->setSpacing ( 0 );
68 leftLayout->setContentsMargins( 0, 1, 0, 1 );
69 rghtLayout->setSpacing ( 0 );
70 rghtLayout->setContentsMargins( 0, 1, 0, 1 );
71 dctlLayout->setSpacing ( 1 );
72 dctlLayout->setContentsMargins( 0, 0, 0, 0 );
73 smryLayout->setSpacing ( 0 );
74 smryLayout->setContentsMargins( 0, 1, 0, 1 );
75 statLayout->setSpacing ( 1 );
76 statLayout->setContentsMargins( 0, 0, 0, 0 );
77 treeLayout->setSpacing ( 1 );
78 treeLayout->setContentsMargins( 0, 0, 0, 0 );
84 dctlLayout->addWidget(
pb_invtor, row, 0, 1, 3 );
90 dctlLayout->addWidget(
le_invtor, row++, 3, 1, 5 );
93 dctlLayout->addWidget(
pb_reset, row, 0, 1, 4 );
94 connect(
pb_reset, SIGNAL( clicked() ),
95 this, SLOT (
reset() ) );
98 dctlLayout->addWidget(
pb_scanda, row++, 4, 1, 4 );
103 dctlLayout->addWidget(
pb_hsedit, row, 0, 1, 4 );
108 dctlLayout->addWidget(
pb_hsmodl, row++, 4, 1, 4 );
113 dctlLayout->addWidget(
pb_hsnois, row, 0, 1, 4 );
118 dctlLayout->addWidget(
pb_helpdt, row++, 4, 1, 4 );
121 dctlLayout->addWidget(
pb_help, row, 0, 1, 4 );
122 connect(
pb_help, SIGNAL( clicked() ),
123 this, SLOT(
help() ) );
126 dctlLayout->addWidget(
pb_close, row++, 4, 1, 4 );
127 connect(
pb_close, SIGNAL( clicked() ),
128 this, SLOT( close() ) );
130 QLabel* lb_runid =
us_label( tr(
"RunID:" ) );
133 dctlLayout->addWidget( lb_runid, row, 0, 1, 2 );
134 dctlLayout->addWidget(
cb_runid, row++, 2, 1, 6 );
135 connect(
cb_runid, SIGNAL( currentIndexChanged( QString ) ),
138 QLabel* lb_triple =
us_label( tr(
"Triple:" ) );
141 dctlLayout->addWidget( lb_triple, row, 0, 1, 2 );
142 dctlLayout->addWidget(
cb_triple, row++, 2, 1, 6 );
144 QLabel* lb_source =
us_label( tr(
"Source:" ) );
149 cb_source ->addItem(
"Exclude Local-Only Trees" );
150 cb_source ->addItem(
"Exclude DB-Only Trees" );
151 dctlLayout->addWidget( lb_source, row, 0, 1, 2 );
152 dctlLayout->addWidget(
cb_source, row++, 2, 1, 6 );
155 tr(
"Use an Investigator dialog to set the database person ID" ) );
157 tr(
"Scan Database and Local data, with content analysis" ) );
159 tr(
"Show a short Help/Legend dialog for notes on the data tree" ) );
161 tr(
"Reset the data display to its default state" ) );
163 tr(
"Display detailed US_ManageData documentation text and images" ) );
165 tr(
"Close the US_ManageData window and exit" ) );
167 tr(
"Select a single run ID with which to populate the data tree " ) );
169 tr(
"Select a single triple of the run to populate the data tree " ) );
171 tr(
"Select a filter to limit records based on source (DB/Local) " ) );
173 QLabel* lb_info2 =
us_banner( tr(
"User Data Sets Summary:" ) );
174 dctlLayout->addWidget( lb_info2, row++, 0, 1, 8 );
179 te_status->setTextBackgroundColor( pa.color( QPalette::Window ) );
180 te_status->setTextColor( pa.color( QPalette::WindowText ) );
184 tr(
" 0 Combined Total data sets;\n"
185 " 0 Combined RawData records;\n"
186 " 0 Combined EditedData records;\n"
187 " 0 Combined Model records;\n"
188 " 0 Combined Noise records.\n"
189 " 0 Database Total data sets;\n"
190 " 0 Database RawData records;\n"
191 " 0 Database EditedData records;\n"
192 " 0 Database Model records;\n"
193 " 0 Database Noise records.\n"
194 " 0 Local Total data sets;\n"
195 " 0 Local RawData records;\n"
196 " 0 Local EditedData records;\n"
197 " 0 Local Model records;\n"
198 " 0 Local Noise records.\n" ) );
199 smryLayout->addWidget( te_status );
200 QFontMetrics fm( te_status->font() );
201 DbgLv(1) <<
"te_status font family" << te_status->font().family();
202 int fontw = fm.maxWidth();
203 fontw = ( fontw > 0 ) ? fontw : fm.width(
'W' );
204 int fonth = fm.lineSpacing();
205 int minsw = fontw * 44 + 10;
206 int minsh = fonth * 18 + 10;
207 DbgLv(1) <<
"te_status fw fh mw mh" << fontw << fonth <<
" " << minsw << minsh;
208 int maxsw = ( minsw * 5 ) / 4;
209 int maxsh = ( minsh * 5 ) / 4;
211 if ( maxsw > 500 || maxsh > 450 )
213 maxsw = qMin( maxsw, 500 );
214 maxsh = qMin( maxsh, 450 );
215 minsw = ( maxsw * 4 ) / 5;
216 minsh = ( maxsh * 4 ) / 5;
219 cb_runid ->setMaximumSize( ( maxsw * 3 ) / 4, fonth * 2 );
220 cb_triple->setMaximumSize( ( maxsw * 3 ) / 4, fonth * 2 );
221 cb_source->setMaximumSize( ( maxsw * 3 ) / 4, fonth * 2 );
223 te_status->setMinimumSize( minsw, minsh );
224 te_status->setMaximumSize( maxsw, maxsh );
225 DbgLv(1) <<
"te_status minw minh" << minsw << minsh;
226 DbgLv(1) <<
"te_status maxw maxh" << maxsw << maxsh;
227 te_status->adjustSize();
228 DbgLv(1) <<
"te_status size" << te_status->size();
231 QLabel* lb_progr =
us_label( tr(
"% Completed:" ) );
233 statLayout->addWidget( lb_progr, row, 0, 1, 4 );
234 statLayout->addWidget(
progress, row++, 4, 1, 4 );
237 statLayout->addWidget(
lb_status, row, 0, 1, 8 );
242 tw_recs->setPalette( te_status->palette() );
243 treeLayout->addWidget(
tw_recs );
246 theads <<
"Type" <<
"Label" <<
"SubType" <<
"Source"
247 <<
"Children\nDB, Local" <<
"Descendants\nDB, Local";
250 tw_recs->setHeaderLabels( theads );
253 tw_recs->setObjectName( QString(
"tree-widget" ) );
254 tw_recs->setAutoFillBackground(
true );
255 tw_recs->installEventFilter(
this );
256 tw_recs->setSelectionMode( QAbstractItemView::ExtendedSelection );
258 connect(
tw_recs, SIGNAL( itemClicked( QTreeWidgetItem*,
int ) ),
264 leftLayout->addLayout( dctlLayout );
265 leftLayout->addLayout( smryLayout );
266 leftLayout->setStretchFactor( smryLayout, 10 );
267 leftLayout->addLayout( statLayout );
268 rghtLayout->addLayout( treeLayout );
270 mainLayout->addLayout( leftLayout );
271 mainLayout->addLayout( rghtLayout );
272 mainLayout->setStretchFactor( leftLayout, 2 );
273 mainLayout->setStretchFactor( rghtLayout, 8 );
275 setMinimumWidth( (
int)( maxsw * 2.6 ) );
284 QMessageBox::information(
this,
285 tr(
"DB Connection Problem" ),
286 tr(
"There was an error connecting to the database:\n" )
289 + tr(
"Continuing without database." ) );
293 DbgLv(1) <<
"db passwd complete";
297 DbgLv(1) <<
"GUI setup complete";
314 DbgLv(1) <<
"classes setup complete";
344 if ( obj->objectName() ==
"tree-widget" &&
345 e->type() == QEvent::ContextMenu )
353 return US_Widgets::eventFilter( obj, e );
360 bool show =
pb_hsedit->text().startsWith(
"Show" );
381 bool show =
pb_hsmodl->text().startsWith(
"Show" );
403 bool show =
pb_hsnois->text().startsWith(
"Show" )
404 ||
pb_hsnois->text().startsWith(
"Expand" );
425 bool edts,
bool mods,
bool nois )
434 pb_hsedit->setText( tr(
"Collapse All" ) );
436 tr(
"Collapse All, so Edits and all descendants are hidden" ) );
441 pb_hsmodl->setText( tr(
"Hide All Models" ) );
443 tr(
"Collapse Edits, so Models and their children are hidden" ) );
448 pb_hsnois->setText( tr(
"Hide All Noises" ) );
450 tr(
"Collapse Models, so Noises are hidden" ) );
458 pb_hsedit->setText( tr(
"Show All Edits" ) );
460 tr(
"Expand Raws, so Edits and parent Raws are shown" ) );
465 pb_hsmodl->setText( tr(
"Show All Models" ) );
467 tr(
"Expand Edits, so Models and their parents are shown" ) );
472 pb_hsnois->setText( tr(
"Expand All" ) );
474 tr(
"Expand All, so Noises and all ancestors are shown" ) );
482 QString rF =
cb_runid ->currentText();
491 lb_status->setText( tr(
"Building Data Tree..." ) );
492 qApp->processEvents();
497 lb_status->setText( tr(
"Data Tree Build Complete" ) );
498 qApp->processEvents();
503 for (
int jj = 0; jj <
ntcols; jj++ )
505 tw_recs->resizeColumnToContents( jj );
510 this->resize( 1000, 500 );
528 SIGNAL( investigator_accepted(
int ) ),
564 return tr(
"This item exists on %1.<br>"
565 "Are you sure you want to proceed with a %2?<ul>"
566 "<li><b>No </b> to cancel the action;</li>"
567 "<li><b>Yes</b> to proceed with the action.</li></ul>" )
568 .arg( exstext ).arg( acttext );
583 lb_status->setText( tr(
"\"%1\" Success!" ).arg( item_act ) );
588 QMessageBox::warning(
this,
589 item_act + tr(
" *ERROR*!" ),
590 tr(
"The \"%1\" action had an error: %2" )
591 .arg( item_act ).arg( stat ) );
592 lb_status->setText( tr(
"\"%1\" ERROR!" ).arg( item_act ) );
601 lb_status->setText( tr(
"\"%1\" Cancelled!" ).arg( item_act ) );
618 for (
int ii = 0; ii <
ncrecs; ii++ )
662 QString().sprintf(
"%5d", ncrecs ) +
663 tr(
" Combined Total data sets;\n " ) +
664 QString().sprintf(
"%5d",
ncraws ) +
665 tr(
" Combined RawData records;\n " ) +
666 QString().sprintf(
"%5d",
ncedts ) +
667 tr(
" Combined EditedData records;\n " ) +
668 QString().sprintf(
"%5d",
ncmods ) +
669 tr(
" Combined Model records;\n " ) +
670 QString().sprintf(
"%5d",
ncnois ) +
671 tr(
" Combined Noise records.\n" ) +
672 QString().sprintf(
"%5d",
ndrecs ) +
673 tr(
" Database Total data sets;\n " ) +
674 QString().sprintf(
"%5d",
ndraws ) +
675 tr(
" Database RawData records;\n " ) +
676 QString().sprintf(
"%5d",
ndedts ) +
677 tr(
" Database EditedData records;\n " ) +
678 QString().sprintf(
"%5d",
ndmods ) +
679 tr(
" Database Model records;\n " ) +
680 QString().sprintf(
"%5d", ndnois ) +
681 tr(
" Database Noise records.\n" ) +
682 QString().sprintf(
"%5d", nlrecs ) +
683 tr(
" Local Total data sets;\n " ) +
684 QString().sprintf(
"%5d", nlraws ) +
685 tr(
" Local RawData records;\n " ) +
686 QString().sprintf(
"%5d", nledts ) +
687 tr(
" Local EditedData records;\n " ) +
688 QString().sprintf(
"%5d", nlmods ) +
689 tr(
" Local Model records;\n " ) +
690 QString().sprintf(
"%5d", nlnois ) +
691 tr(
" Local Noise records.\n" ) );
697 DbgLv(0) <<
"selected_runID: selrunID" << selrunID;
698 if ( selrunID.isEmpty() || selrunID ==
"ALL" )
705 lb_status->setText( tr(
"Scanning triples for a run..." ) );
706 qApp->processEvents();
707 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
709 DbgLv(0) <<
"selected_runID: da_m getTriples size" <<
triples.size();
714 QApplication::restoreOverrideCursor();
718 ( ntriple == 1 ) ? tr(
"The run has a single triple" )
719 : tr(
"%1 triples are available to select" ).arg( ntriple ) );