| 1 |
/* |
| 2 |
TimerTable window for AviCap |
| 3 |
|
| 4 |
written 2003 by Alexander Rawass ([email protected]) |
| 5 |
*/ |
| 6 |
|
| 7 |
#include "timertable.h" |
| 8 |
#include "timertable.moc" |
| 9 |
|
| 10 |
#include "vidconf.h" |
| 11 |
#include "v4lwindow.h" |
| 12 |
#include "capproc.h" |
| 13 |
#include "codecdialog.h" |
| 14 |
#include "avicapwnd.h" |
| 15 |
|
| 16 |
#include <avm_fourcc.h> |
| 17 |
#include <avm_cpuinfo.h> |
| 18 |
#include <avm_creators.h> |
| 19 |
#include <avm_output.h> |
| 20 |
#include <utils.h> |
| 21 |
#define DECLARE_REGISTRY_SHORTCUT |
| 22 |
#include <configfile.h> |
| 23 |
#undef DECLARE_REGISTRY_SHORTCUT |
| 24 |
|
| 25 |
#include <qcheckbox.h> |
| 26 |
#include <qcombobox.h> |
| 27 |
#include <qfiledialog.h> |
| 28 |
#include <qlabel.h> |
| 29 |
#include <qlineedit.h> |
| 30 |
#include <qpushbutton.h> |
| 31 |
#include <qspinbox.h> |
| 32 |
#include <qtabwidget.h> |
| 33 |
#include <qlistview.h> |
| 34 |
#include <qcombobox.h> |
| 35 |
#include <qsplitter.h> |
| 36 |
#include <qgroupbox.h> |
| 37 |
#include <qlayout.h> |
| 38 |
#include <qpushbutton.h> |
| 39 |
#include <qbuttongroup.h> |
| 40 |
#include <qmessagebox.h> |
| 41 |
#include <qtabwidget.h> |
| 42 |
|
| 43 |
#if QT_VERSION>=300 |
| 44 |
#include <qdatetimeedit.h> |
| 45 |
#endif |
| 46 |
#include <epgwindow.h> |
| 47 |
|
| 48 |
#include <unistd.h> |
| 49 |
#include <stdio.h> |
| 50 |
#include <stdlib.h> // atof |
| 51 |
#include <sys/vfs.h> //statfs |
| 52 |
|
| 53 |
|
| 54 |
TimerTableItem::TimerTableItem(QListView *parent,TimerTable *timer_win,V4LWindow *v4lw,int ch,QDateTime start,QTime stop,QString fname,QString desc,int whentime,int whatday,QString codec) |
| 55 |
: QCheckListItem(parent,"test",QCheckListItem::CheckBox), avm::AvmOutputLog("TimerTableItem") |
| 56 |
{ |
| 57 |
timer_window=timer_win; |
| 58 |
my_v4lwin=v4lw; |
| 59 |
|
| 60 |
setTable(ch,start,stop,fname,desc,whentime,whatday,codec); |
| 61 |
} |
| 62 |
|
| 63 |
/* **************************************** */ |
| 64 |
|
| 65 |
TimerTableItem::~TimerTableItem(){ |
| 66 |
} |
| 67 |
|
| 68 |
void TimerTable::setEpgWindow(EpgWindow *win){ |
| 69 |
epgwin=win; |
| 70 |
|
| 71 |
connect((const QObject *)win,SIGNAL(emitAddRecording(EpgProgram *)),this,SLOT(addEpgRecording(EpgProgram *))); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
void TimerTableItem::checkWhen(){ |
| 77 |
QDateTime currentdatetime=QDateTime::currentDateTime(); |
| 78 |
QDate currentdate=QDate::currentDate(); |
| 79 |
QTime currenttime=currentdatetime.time(); |
| 80 |
QTime start_timeonly=start_time.time(); |
| 81 |
QTime stop_timeonly=stop_datetime.time(); |
| 82 |
|
| 83 |
|
| 84 |
if(when==0){ |
| 85 |
//once, do nothing |
| 86 |
} |
| 87 |
else if(when==1){ |
| 88 |
//tomorrow |
| 89 |
start_time=currentdatetime.addDays(1); |
| 90 |
when=0; //set back to once |
| 91 |
} |
| 92 |
else if(when==2){ |
| 93 |
//day after tomorrow |
| 94 |
start_time=currentdatetime.addDays(2); |
| 95 |
when=0; |
| 96 |
} |
| 97 |
else if(when==3){ |
| 98 |
//every |
| 99 |
if(day==0){ |
| 100 |
//every day |
| 101 |
|
| 102 |
if(start_timeonly<currenttime && stop_timeonly>currenttime){ |
| 103 |
// it is NOW |
| 104 |
start_time.setDate(currentdate); |
| 105 |
} |
| 106 |
else if(start_timeonly<currenttime){ |
| 107 |
// it is in the past |
| 108 |
// so set it to tomorrow |
| 109 |
start_time.setDate(currentdate.addDays(1)); |
| 110 |
} |
| 111 |
else{ |
| 112 |
// the start time is in the future |
| 113 |
start_time.setDate(currentdate); |
| 114 |
} |
| 115 |
}//end of day==0 |
| 116 |
else{ |
| 117 |
// day 1..7 = Mon .. Sun |
| 118 |
int currentday=currentdate.dayOfWeek(); |
| 119 |
if(currentday==day){ |
| 120 |
// the same weekday as today |
| 121 |
if(start_timeonly<currenttime && stop_timeonly>currenttime){ |
| 122 |
// it is NOW |
| 123 |
start_time.setDate(currentdate); |
| 124 |
} |
| 125 |
else if(start_timeonly<currenttime){ |
| 126 |
// it is in the past |
| 127 |
// so set it to next day with the wanted weekday |
| 128 |
start_time.setDate(currentdate); |
| 129 |
do{ |
| 130 |
start_time=start_time.addDays(1); |
| 131 |
}while(start_time.date().dayOfWeek()!=day); |
| 132 |
} |
| 133 |
else{ |
| 134 |
// the start time is in the future |
| 135 |
start_time.setDate(currentdate); |
| 136 |
} |
| 137 |
}//end of 'currentday == day' |
| 138 |
else{ |
| 139 |
//not the same weekday as today |
| 140 |
start_time.setDate(currentdate); |
| 141 |
do{ |
| 142 |
start_time=start_time.addDays(1); |
| 143 |
}while(start_time.date().dayOfWeek()!=day); |
| 144 |
}//end of 'currentday!=day' |
| 145 |
|
| 146 |
}//end of 'day == 1...7' |
| 147 |
}//end of 'when==3' |
| 148 |
|
| 149 |
else if(when==4){ |
| 150 |
//next |
| 151 |
} |
| 152 |
else{ |
| 153 |
printf("ERROR: unknown when\n"); |
| 154 |
} |
| 155 |
|
| 156 |
setTable(channel_nr,start_time,stop_time,filename,description,when,day,named_codec); |
| 157 |
} |
| 158 |
|
| 159 |
void TimerTableItem::paintCell(QPainter * p, const QColorGroup & cg, int column, int width, int align) |
| 160 |
{ |
| 161 |
//printf("paintcell!\n"); |
| 162 |
QColorGroup new_cg=QColorGroup(cg); |
| 163 |
|
| 164 |
// new_cg.setColor(QColorGroup::Base,QColor(0xf3,0xfc,0xc7)); |
| 165 |
|
| 166 |
QDateTime currenttime=QDateTime::currentDateTime(); |
| 167 |
|
| 168 |
QColor textcol; |
| 169 |
|
| 170 |
if(stop_datetime<currenttime){ |
| 171 |
textcol=QColor(0,0,200); |
| 172 |
new_cg.setColor(QColorGroup::Highlight,QColor(0,0,150)); |
| 173 |
} |
| 174 |
if(start_time>currenttime){ |
| 175 |
textcol=QColor(0,0,0); |
| 176 |
} |
| 177 |
if(this==timer_window->getNextRecording()){ |
| 178 |
textcol=QColor(0,0,0); |
| 179 |
new_cg.setColor(QColorGroup::Highlight,QColor(0,150,0)); |
| 180 |
new_cg.setColor(QColorGroup::Base,QColor(180,255,180)); |
| 181 |
} |
| 182 |
if(this==timer_window->getCurrentRecording()){ |
| 183 |
textcol=QColor(0,0,0); |
| 184 |
new_cg.setColor(QColorGroup::Highlight,QColor(150,0,0)); |
| 185 |
new_cg.setColor(QColorGroup::Base,QColor(255,160,160)); |
| 186 |
} |
| 187 |
|
| 188 |
new_cg.setColor(QColorGroup::Text,textcol); |
| 189 |
|
| 190 |
//new_cg.setColor(QColorGroup::Foreground,QColor(255,0,0)); |
| 191 |
//new_cg.setColor(QColorGroup::Background,QColor(0,255,0)); |
| 192 |
//new_cg.setColor(QColorGroup::Button,QColor(255,0,255)); |
| 193 |
//new_cg.setColor(QColorGroup::ButtonText,QColor(255,0,255)); |
| 194 |
//new_cg.setColor(QColorGroup::Highlight,QColor(100,0,255)); |
| 195 |
//new_cg.setColor(QColorGroup::HighlightedText,QColor(255,100,255)); |
| 196 |
QCheckListItem::paintCell(p,new_cg,column,width,align); |
| 197 |
} |
| 198 |
|
| 199 |
int TimerTableItem::compare(QListViewItem *other,int col, bool ascend) const { |
| 200 |
if(other==NULL){ |
| 201 |
return 0; |
| 202 |
} |
| 203 |
|
| 204 |
TimerTableItem *other_tti=(TimerTableItem *)other; |
| 205 |
int result=0; |
| 206 |
|
| 207 |
if(col==2){ |
| 208 |
//start time |
| 209 |
if(getStartTime()==other_tti->getStartTime()){ |
| 210 |
result=0; |
| 211 |
} |
| 212 |
else{ |
| 213 |
result=(getStartTime()>other_tti->getStartTime()) ? -1 : 1 ; |
| 214 |
} |
| 215 |
} |
| 216 |
else if(col==3){ |
| 217 |
//stop time |
| 218 |
if(getStopDateTime()==other_tti->getStopDateTime()){ |
| 219 |
result=0; |
| 220 |
} |
| 221 |
else{ |
| 222 |
result=(getStopDateTime()>other_tti->getStopDateTime()) ? -1 : 1; |
| 223 |
} |
| 224 |
} |
| 225 |
else{ |
| 226 |
#if QT_VERSION>=300 |
| 227 |
result=QListViewItem::compare(other,col,ascend); |
| 228 |
#else |
| 229 |
#warning "fixme: QListViewItem::compare" |
| 230 |
printf("fixme: QListViewItem::compare for QT23\n"); |
| 231 |
result=0; |
| 232 |
#endif |
| 233 |
|
| 234 |
} |
| 235 |
|
| 236 |
return result; |
| 237 |
} |
| 238 |
|
| 239 |
/* **************************************** */ |
| 240 |
|
| 241 |
// sets an entry in the table to new values |
| 242 |
|
| 243 |
void TimerTableItem::setTable(int ch,QDateTime start,QTime stop,QString fname,QString desc,int whentime,int whatday,QString codec) { |
| 244 |
channel_nr=ch; |
| 245 |
start_time=start; |
| 246 |
stop_time=stop; |
| 247 |
filename=fname; |
| 248 |
description=desc; |
| 249 |
when=whentime; |
| 250 |
day=whatday; |
| 251 |
named_codec=codec; |
| 252 |
|
| 253 |
stop_datetime=timer_window->calc_stopDateTime(start_time,stop_time); |
| 254 |
|
| 255 |
#if QT_VERSION>=300 |
| 256 |
QString start_timestr=start_time.toString(my_dateformat); |
| 257 |
#else |
| 258 |
QString weekday=start_time.date().dayName(start_time.date().dayOfWeek()); |
| 259 |
QString start_timestr=dateTimeToString(start_time)+QString(" ")+weekday; |
| 260 |
#endif |
| 261 |
|
| 262 |
QString stop_timestr=stop_time.toString(my_timeformat); |
| 263 |
QString numstr; |
| 264 |
|
| 265 |
//setText(0,QString::number(channel_nr)); |
| 266 |
setText(0,description); |
| 267 |
//setText(1,QString::number(channel_nr+1)+" - "+QString(my_v4lwin->getXawtvStation(channel_nr).c_str())); |
| 268 |
setText(1,numstr.sprintf("%02d",channel_nr+1)+" - "+QString(my_v4lwin->getXawtvStation(channel_nr).c_str())); |
| 269 |
setText(2,start_timestr); |
| 270 |
setText(3,stop_timestr); |
| 271 |
setText(4,named_codec); |
| 272 |
setText(5,filename); |
| 273 |
} |
| 274 |
|
| 275 |
/* **************************************** */ |
| 276 |
void TimerTable::addEpgRecording(EpgProgram *prog){ |
| 277 |
printf("signal got\n"); |
| 278 |
QDateTime start=prog->start; |
| 279 |
QDateTime stop=prog->stop; |
| 280 |
|
| 281 |
start=start.addSecs(-RI("EpgMinBeforeProgram",5)*60); |
| 282 |
stop=stop.addSecs(RI("EpgMinBeforeProgram",5)*60); |
| 283 |
|
| 284 |
TimerTableItem *item=new TimerTableItem(table,this,my_v4lw,prog->channelnr-1,start,stop.time(),"epgprogram.avi",prog->title,0,0,RS("NamedCodecsCurrent","-Default-")); |
| 285 |
|
| 286 |
AVMOUT(AVML_DEBUG, "Added recording from EPG: %s from %s to %s", |
| 287 |
prog->title.latin1(),start.toString().latin1(), |
| 288 |
stop.toString().latin1()); |
| 289 |
} |
| 290 |
|
| 291 |
/* **************************************** */ |
| 292 |
|
| 293 |
// creates the timertable |
| 294 |
|
| 295 |
TimerTable::TimerTable(QWidget* parent, v4lxif* v4l, V4LWindow* w) |
| 296 |
: QDialog( NULL, "Avicap Timertable", false), avm::AvmOutputLog("TimerTable") |
| 297 |
{ |
| 298 |
my_v4lxif=v4l; |
| 299 |
my_v4lw=w; |
| 300 |
|
| 301 |
AVMOUT(AVML_DEBUG, tr("TimerTable started")); |
| 302 |
|
| 303 |
setMinimumSize(600,700); |
| 304 |
//setMaximumSize(800,800); |
| 305 |
setCaption( tr("AviCap Timertable") ); |
| 306 |
|
| 307 |
timer_mode=TimerOff; |
| 308 |
next_recording=NULL; |
| 309 |
current_recording=NULL; |
| 310 |
last_item_clicked=NULL; |
| 311 |
shutdown_message=NULL; |
| 312 |
epgwin=NULL; |
| 313 |
|
| 314 |
|
| 315 |
splitter1=new QSplitter(QSplitter::Vertical,this); |
| 316 |
splitter1->setOpaqueResize(true); |
| 317 |
|
| 318 |
table=new QListView(splitter1); |
| 319 |
table->setBaseSize(600,200); |
| 320 |
table->setMinimumSize(600,200); |
| 321 |
// table->setMaximumSize(800,800); |
| 322 |
table->setSelectionMode(QListView::Single); |
| 323 |
connect(table,SIGNAL(pressed(QListViewItem *)),this,SLOT(item_clicked(QListViewItem *))); |
| 324 |
|
| 325 |
//table->addColumn("ChNr"); |
| 326 |
table->addColumn(tr("Description")); |
| 327 |
table->addColumn(tr("Channel Name")); |
| 328 |
table->addColumn(tr("Start Recording")); |
| 329 |
table->addColumn(tr("End Rec")); |
| 330 |
table->addColumn(tr("Codec")); |
| 331 |
//table->setColumnAlignment(3,Qt::AlignRight); |
| 332 |
table->setColumnAlignment(3,Qt::AlignHCenter); |
| 333 |
table->addColumn(tr("Filename")); |
| 334 |
//table->setItemMargin(5); |
| 335 |
table->setAllColumnsShowFocus(true); |
| 336 |
table->setShowSortIndicator(true); |
| 337 |
table->setSorting(2,true); |
| 338 |
table->sort(); |
| 339 |
|
| 340 |
all_box=new QGroupBox(1,Qt::Horizontal,splitter1); |
| 341 |
all_box->setBaseSize(600,600); |
| 342 |
all_box->setMinimumSize(600,600); |
| 343 |
// all_box->setMaximumSize(600,800); |
| 344 |
|
| 345 |
splitter1->setResizeMode(all_box,QSplitter::Stretch); |
| 346 |
splitter1->setResizeMode(table,QSplitter::Stretch); |
| 347 |
|
| 348 |
//edit_box=new QGroupBox(2,Qt::Horizontal,all_box); |
| 349 |
edit_box=new QWidget(all_box); |
| 350 |
//edit_box=new QGroupBox(splitter1); |
| 351 |
edit_box->setBaseSize(600,200); |
| 352 |
|
| 353 |
|
| 354 |
QGridLayout* gl = new QGridLayout( edit_box, 1, 1 ); |
| 355 |
gl->setSpacing( 5 ); |
| 356 |
gl->setMargin( 5 ); |
| 357 |
|
| 358 |
int row=0; |
| 359 |
|
| 360 |
when_combobox=new QComboBox(edit_box); |
| 361 |
gl->addWidget(when_combobox,row,0); |
| 362 |
when_combobox->insertItem(tr("once")); |
| 363 |
when_combobox->insertItem(tr("tomorrow")); |
| 364 |
when_combobox->insertItem(tr("day after tomorrow")); |
| 365 |
when_combobox->insertItem(tr("every")); |
| 366 |
when_combobox->insertItem(tr("next")); |
| 367 |
|
| 368 |
day_combobox=new QComboBox(edit_box); |
| 369 |
gl->addWidget(day_combobox,row,1); |
| 370 |
|
| 371 |
day_combobox->insertItem(tr("day")); |
| 372 |
for(int i=1; i<=7;i++){ |
| 373 |
#if QT_VERSION>=300 |
| 374 |
day_combobox->insertItem(QDate::longDayName(i)); |
| 375 |
#else |
| 376 |
QDate bogus; |
| 377 |
day_combobox->insertItem(bogus.dayName(i)); |
| 378 |
#endif |
| 379 |
} |
| 380 |
|
| 381 |
row++; |
| 382 |
QLabel *l=new QLabel(tr("Start Date/Time:"),edit_box); |
| 383 |
gl->addWidget(l,row,0); |
| 384 |
|
| 385 |
begin_timeedit=new QDateTimeEdit(edit_box,"start_time"); |
| 386 |
gl->addWidget(begin_timeedit,row,1); |
| 387 |
|
| 388 |
row++; |
| 389 |
QLabel *l2=new QLabel(tr("End Time:"),edit_box); |
| 390 |
gl->addWidget(l2,row,0); |
| 391 |
end_timeedit=new QTimeEdit(edit_box,"end_time"); |
| 392 |
gl->addWidget(end_timeedit,row,1); |
| 393 |
|
| 394 |
row++; |
| 395 |
QLabel *l3=new QLabel(tr("Channel:"),edit_box); |
| 396 |
gl->addWidget(l3,row,0); |
| 397 |
channelbox=new QComboBox(edit_box,"channel"); |
| 398 |
gl->addWidget(channelbox,row,1); |
| 399 |
|
| 400 |
if (my_v4lw->getStations()) |
| 401 |
{ |
| 402 |
char cbuf[100]; |
| 403 |
|
| 404 |
for (int i = 0; i < my_v4lw->getStations(); i++){ |
| 405 |
sprintf(cbuf,"%-2d %s",i+1,my_v4lw->getXawtvStation(i).c_str()); |
| 406 |
channelbox->insertItem(cbuf); |
| 407 |
} |
| 408 |
} |
| 409 |
|
| 410 |
row++; |
| 411 |
QLabel *l444=new QLabel(tr("Codec:"),edit_box); |
| 412 |
gl->addWidget(l444,row,0); |
| 413 |
codecbox=new QComboBox(edit_box,"codec"); |
| 414 |
gl->addWidget(codecbox,row,1); |
| 415 |
|
| 416 |
|
| 417 |
QString named_codecs_current=RS("NamedCodecsCurrent","-Default-"); |
| 418 |
recreateCodecBox(named_codecs_current); |
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
row++; |
| 425 |
QLabel *l4=new QLabel(tr("Filename:"),edit_box); |
| 426 |
gl->addWidget(l4,row,0); |
| 427 |
filename_edit=new QLineEdit(edit_box,"filename"); |
| 428 |
gl->addWidget(filename_edit,row,1); |
| 429 |
|
| 430 |
row++; |
| 431 |
QLabel *l5=new QLabel(tr("Description"),edit_box); |
| 432 |
gl->addWidget(l5,row,0); |
| 433 |
description_edit=new QLineEdit(edit_box,"description"); |
| 434 |
gl->addWidget(description_edit,row,1); |
| 435 |
|
| 436 |
|
| 437 |
edit_box->hide(); |
| 438 |
|
| 439 |
edit_buttons=new QButtonGroup(3,Qt::Horizontal,all_box); |
| 440 |
|
| 441 |
new_button=new QPushButton(tr("new"),edit_buttons); |
| 442 |
modify_button=new QPushButton(tr("modify"),edit_buttons); |
| 443 |
remove_button=new QPushButton(tr("remove"),edit_buttons); |
| 444 |
|
| 445 |
rec_buttons=new QButtonGroup(2,Qt::Horizontal,all_box); |
| 446 |
|
| 447 |
rec_start_button=new QPushButton(tr("start timer"),rec_buttons); |
| 448 |
|
| 449 |
shutdown_checkbox=new QCheckBox(tr("shutdown when allowed"),rec_buttons); |
| 450 |
|
| 451 |
connect(new_button,SIGNAL(pressed()),this,SLOT(button_new_pressed())); |
| 452 |
connect(modify_button,SIGNAL(pressed()),this,SLOT(button_modify_pressed())); |
| 453 |
connect(remove_button,SIGNAL(pressed()),this,SLOT(button_remove_pressed())); |
| 454 |
|
| 455 |
connect(rec_start_button,SIGNAL(pressed()),this,SLOT(button_start_pressed())); |
| 456 |
|
| 457 |
QWidget *wi=new QWidget(all_box); |
| 458 |
QVBoxLayout *lo=new QVBoxLayout(wi); |
| 459 |
status_label=new QLabel(wi); |
| 460 |
lo->addWidget(status_label); |
| 461 |
|
| 462 |
init_entry_widgets(); |
| 463 |
|
| 464 |
load(); |
| 465 |
if(table->childCount()>0){ |
| 466 |
edit_box->show(); |
| 467 |
|
| 468 |
TimerTableItem *first_item=(TimerTableItem *)table->firstChild(); |
| 469 |
table->setCurrentItem(first_item); |
| 470 |
table->setSelected(first_item,true); |
| 471 |
last_item_clicked=first_item; |
| 472 |
|
| 473 |
item_clicked(first_item); |
| 474 |
} |
| 475 |
|
| 476 |
set_status_label(); |
| 477 |
|
| 478 |
next_recording=find_first_recording(); |
| 479 |
if(next_recording){ |
| 480 |
table->ensureItemVisible(next_recording); |
| 481 |
table->setCurrentItem(next_recording); |
| 482 |
table->setSelected(next_recording,true); |
| 483 |
last_item_clicked=next_recording; |
| 484 |
|
| 485 |
item_clicked(next_recording); |
| 486 |
} |
| 487 |
else{ |
| 488 |
printf("no next recording at startup\n"); |
| 489 |
} |
| 490 |
|
| 491 |
my_timer=new QTimer(this); |
| 492 |
connect(my_timer,SIGNAL(timeout()),SLOT(timer())); |
| 493 |
my_timer->start(1000); |
| 494 |
} |
| 495 |
|
| 496 |
/* **************************************** */ |
| 497 |
|
| 498 |
TimerTable::~TimerTable(){ |
| 499 |
printf("TimerTable has been exited\n"); |
| 500 |
my_timer->stop(); |
| 501 |
save(); |
| 502 |
} |
| 503 |
|
| 504 |
/* **************************************** */ |
| 505 |
|
| 506 |
QString TimerTable::add_current_time_info(){ |
| 507 |
QString result; |
| 508 |
|
| 509 |
result=QString().sprintf(tr("Current Time : %s\n"),QDateTime::currentDateTime().toString(my_dateformat).latin1()); |
| 510 |
|
| 511 |
return result; |
| 512 |
} |
| 513 |
|
| 514 |
/* **************************************** */ |
| 515 |
|
| 516 |
QString TimerTable::add_next_recording_info(){ |
| 517 |
QString result; |
| 518 |
QDateTime currenttime=QDateTime::currentDateTime(); |
| 519 |
|
| 520 |
if(next_recording){ |
| 521 |
int chnr=next_recording->getChannel(); |
| 522 |
avm::string chname=my_v4lw->getXawtvStation(chnr); |
| 523 |
QString fname=next_recording->getFilename(); |
| 524 |
QString desc=next_recording->getDescription(); |
| 525 |
QDateTime starttime=next_recording->getStartTime(); |
| 526 |
|
| 527 |
int diff_in_secs=currenttime.secsTo(starttime); |
| 528 |
//printf("%d secs to wait\n",diff_in_secs); |
| 529 |
|
| 530 |
QString etastring; |
| 531 |
if(diff_in_secs>60*60*24){ |
| 532 |
// more than a day |
| 533 |
int days=diff_in_secs/(60*60*24); |
| 534 |
etastring.sprintf("more than %d days",days); |
| 535 |
} |
| 536 |
else{ |
| 537 |
QTime notime=QTime(); |
| 538 |
QTime eta=notime.addSecs(diff_in_secs); |
| 539 |
|
| 540 |
etastring=eta.toString(my_timeformat); |
| 541 |
} |
| 542 |
result=QString().sprintf(tr("Next Recording: %s #%d %s to %s\n")+ |
| 543 |
tr("\tstarts at %s in %s\n"), |
| 544 |
desc.latin1(),chnr+1,chname.c_str(),fname.latin1(), |
| 545 |
starttime.toString(my_dateformat).latin1(),etastring.latin1()); |
| 546 |
|
| 547 |
} |
| 548 |
else{ |
| 549 |
result=QString().sprintf(tr("No Next Recording\n")); |
| 550 |
} |
| 551 |
|
| 552 |
return result; |
| 553 |
} |
| 554 |
|
| 555 |
/* **************************************** */ |
| 556 |
|
| 557 |
QString TimerTable::add_current_recording_info(){ |
| 558 |
QString result; |
| 559 |
QDateTime currenttime=QDateTime::currentDateTime(); |
| 560 |
|
| 561 |
if(current_recording){ |
| 562 |
QDateTime stoptime=current_recording->getStopDateTime(); |
| 563 |
|
| 564 |
int diff_in_secs=currenttime.secsTo(stoptime); |
| 565 |
//printf("%d secs to go\n",diff_in_secs); |
| 566 |
|
| 567 |
QTime notime=QTime(); |
| 568 |
|
| 569 |
QTime eta=notime.addSecs(diff_in_secs); |
| 570 |
|
| 571 |
int chnr=current_recording->getChannel(); |
| 572 |
|
| 573 |
avm::string chname=my_v4lw->getXawtvStation(chnr); |
| 574 |
|
| 575 |
QString fname=current_recording->getFilename(); |
| 576 |
QString desc=current_recording->getDescription(); |
| 577 |
|
| 578 |
// sprintf(sbuf,tr("Currently Recording: stops at %s in %s\nChannel Nr %d %s %s\nFilename %s\n"),stoptime.toString(my_dateformat).latin1(),eta.toString(my_timeformat).latin1(),chnr+1,chname.c_str(),desc.latin1(),fname.latin1()); |
| 579 |
result=QString().sprintf(tr("Current Recording: %s #%d %s to %s\n\tstops at %s in %s\n"), |
| 580 |
desc.latin1(),chnr+1,chname.c_str(),fname.latin1(), |
| 581 |
stoptime.toString(my_dateformat).latin1(),eta.toString(my_timeformat).latin1()); |
| 582 |
|
| 583 |
} |
| 584 |
else{ |
| 585 |
result=QString().sprintf(tr("No Current Recording\n")); |
| 586 |
} |
| 587 |
|
| 588 |
return result; |
| 589 |
} |
| 590 |
|
| 591 |
/* **************************************** */ |
| 592 |
|
| 593 |
QString TimerTable::add_sanity_check_info(){ |
| 594 |
QString result; |
| 595 |
|
| 596 |
TimerTableItem *item1=(TimerTableItem *)table->firstChild(); |
| 597 |
|
| 598 |
bool insane=false; |
| 599 |
while(!insane && item1!=NULL){ |
| 600 |
if(item1->isOn()){ |
| 601 |
TimerTableItem *item2=(TimerTableItem *)table->firstChild(); |
| 602 |
|
| 603 |
while(!insane && item2!=NULL){ |
| 604 |
if(item2!=item1 && item2->isOn()){ |
| 605 |
QDateTime start1=item1->getStartTime(); |
| 606 |
QDateTime stop1=item1->getStopDateTime(); |
| 607 |
|
| 608 |
QDateTime start2=item2->getStartTime(); |
| 609 |
QDateTime stop2=item2->getStopDateTime(); |
| 610 |
|
| 611 |
if((start1<start2 && start2<stop1) || (start2<start1 && start1<stop2)){ |
| 612 |
// do I have to do more sanity checks??? |
| 613 |
avm::string chn1=my_v4lw->getXawtvStation(item1->getChannel()); |
| 614 |
avm::string chn2=my_v4lw->getXawtvStation(item2->getChannel()); |
| 615 |
|
| 616 |
result=QString().sprintf(tr("Sanity Check failed:\n")+ \ |
| 617 |
"a) %-10s\t#%d %-10s " +tr("from")+" %s to %s\n" + \ |
| 618 |
"b) %-10s\t#%d %-10s "+tr("from")+" %s to %s\n", |
| 619 |
item1->getDescription().latin1(),item1->getChannel()+1,chn1.c_str(), \ |
| 620 |
item1->getStartTime().toString(my_dateformat).latin1(), \ |
| 621 |
item1->getStopDateTime().toString(my_dateformat).latin1(), |
| 622 |
item2->getDescription().latin1(),item2->getChannel()+1,chn2.c_str(), \ |
| 623 |
item2->getStartTime().toString(my_dateformat).latin1(), \ |
| 624 |
item2->getStopDateTime().toString(my_dateformat).latin1()); |
| 625 |
//strcat(bigbuf,sbuf); |
| 626 |
insane=true; |
| 627 |
} |
| 628 |
} |
| 629 |
item2=(TimerTableItem *)item2->nextSibling(); |
| 630 |
} |
| 631 |
} |
| 632 |
|
| 633 |
item1=(TimerTableItem *)item1->nextSibling(); |
| 634 |
} |
| 635 |
|
| 636 |
return result; |
| 637 |
} |
| 638 |
|
| 639 |
/* **************************************** */ |
| 640 |
|
| 641 |
void TimerTable::set_status_label(){ |
| 642 |
|
| 643 |
QDateTime currenttime=QDateTime::currentDateTime(); |
| 644 |
|
| 645 |
if(timer_mode==TimerOff){ |
| 646 |
QString curtim=QString().sprintf(tr("Current Time: %s\nTimer not activated\n"),currenttime.toString(my_dateformat).latin1()); |
| 647 |
//add_next_recording_info(bigbuf); |
| 648 |
//add_sanity_check_info(bigbuf); |
| 649 |
|
| 650 |
status_label->setText(curtim); |
| 651 |
} |
| 652 |
else if(timer_mode==TimerWaiting){ |
| 653 |
QString label; |
| 654 |
label=add_current_time_info(); |
| 655 |
label+=add_next_recording_info(); |
| 656 |
label+=add_sanity_check_info(); |
| 657 |
|
| 658 |
status_label->setText(label); |
| 659 |
} |
| 660 |
else if(timer_mode==TimerRecording){ |
| 661 |
QString label; |
| 662 |
label=add_current_time_info(); |
| 663 |
label+=add_current_recording_info(); |
| 664 |
label+=add_next_recording_info(); |
| 665 |
label+=add_sanity_check_info(); |
| 666 |
|
| 667 |
status_label->setText(label); |
| 668 |
} |
| 669 |
} |
| 670 |
|
| 671 |
/* **************************************** */ |
| 672 |
|
| 673 |
// initializes the entry widgets with default values |
| 674 |
|
| 675 |
void TimerTable::init_entry_widgets(){ |
| 676 |
QDateTime current=QDateTime::currentDateTime(); |
| 677 |
|
| 678 |
begin_timeedit->setDateTime(current); |
| 679 |
|
| 680 |
end_timeedit->setTime(QTime::currentTime()); |
| 681 |
|
| 682 |
filename_edit->setText("./movie.avi"); |
| 683 |
|
| 684 |
channelbox->setCurrentItem(0); |
| 685 |
|
| 686 |
codecbox->setCurrentItem(0); |
| 687 |
|
| 688 |
description_edit->setText("untitled"); |
| 689 |
|
| 690 |
when_combobox->setCurrentItem(0); |
| 691 |
day_combobox->setCurrentItem(0); |
| 692 |
} |
| 693 |
|
| 694 |
/* **************************************** */ |
| 695 |
|
| 696 |
void TimerTable::item_clicked(QListViewItem *lvitem){ |
| 697 |
TimerTableItem *item=(TimerTableItem *)lvitem; |
| 698 |
|
| 699 |
if(item!=NULL){ |
| 700 |
if(item==next_recording){ |
| 701 |
printf("next recording clicked\n"); |
| 702 |
description_edit->setBackgroundColor(QColor(150,0,0)); |
| 703 |
//description_edit->setBackgroundMode(Qt::PaletteDark); |
| 704 |
//description_edit->setPaletteBackgroundColor(QColor(150,0,0)); |
| 705 |
//description_edit->setPaletteForegroundColor(QColor(150,0,0)); |
| 706 |
//description_edit->setEraseColor(QColor(150,0,0)); |
| 707 |
//QPalette pal(QColor(150,0,0),QColor(0,150,0)); |
| 708 |
//QPalette pal; |
| 709 |
//description_edit->setPalette(pal); |
| 710 |
} |
| 711 |
|
| 712 |
begin_timeedit->setDateTime(item->getStartTime()); |
| 713 |
|
| 714 |
end_timeedit->setTime(item->getStopTime()); |
| 715 |
|
| 716 |
filename_edit->setText(item->getFilename()); |
| 717 |
|
| 718 |
channelbox->setCurrentItem(item->getChannel()); |
| 719 |
|
| 720 |
description_edit->setText(item->getDescription()); |
| 721 |
|
| 722 |
when_combobox->setCurrentItem(item->getWhen()); |
| 723 |
day_combobox->setCurrentItem(item->getDay()); |
| 724 |
|
| 725 |
recreateCodecBox(item->getNamedCodec()); |
| 726 |
|
| 727 |
last_item_clicked=item; |
| 728 |
} |
| 729 |
} |
| 730 |
|
| 731 |
void TimerTable::recreateCodecBox(QString set_name){ |
| 732 |
while(codecbox->count()>0){ |
| 733 |
codecbox->removeItem(0); |
| 734 |
} |
| 735 |
|
| 736 |
codecbox->insertItem("-Default-"); |
| 737 |
codecbox->setEditable(false); |
| 738 |
codecbox->setCurrentItem(0); |
| 739 |
|
| 740 |
{ |
| 741 |
int i=0; |
| 742 |
|
| 743 |
QString regname=QString().sprintf("NamedCodecs-%02d-Savename",i); |
| 744 |
QString nc_savename=RS(regname,"NONE"); |
| 745 |
|
| 746 |
while(nc_savename!="NONE"){ |
| 747 |
regname=QString().sprintf("NamedCodecs-%02d-Codec",i); |
| 748 |
QString nc_codec=RS(regname,"NONE"); |
| 749 |
|
| 750 |
//codecbox->insertItem(nc_savename); |
| 751 |
|
| 752 |
i++; |
| 753 |
|
| 754 |
regname=QString().sprintf("NamedCodecs-%02d-Savename",i); |
| 755 |
nc_savename=RS(regname,"NONE"); |
| 756 |
} |
| 757 |
|
| 758 |
|
| 759 |
for(int j=0;j<codecbox->count();j++){ |
| 760 |
if(codecbox->text(j)==set_name){ |
| 761 |
codecbox->setCurrentItem(j); |
| 762 |
} |
| 763 |
} |
| 764 |
} |
| 765 |
|
| 766 |
} |
| 767 |
|
| 768 |
|
| 769 |
/* **************************************** */ |
| 770 |
|
| 771 |
void TimerTable::button_new_pressed(){ |
| 772 |
edit_box->show(); |
| 773 |
init_entry_widgets(); |
| 774 |
TimerTableItem *newitem=set_tableitem(NULL); |
| 775 |
|
| 776 |
table->setCurrentItem(newitem); |
| 777 |
table->setSelected(newitem,true); |
| 778 |
last_item_clicked=newitem; |
| 779 |
} |
| 780 |
|
| 781 |
/* **************************************** */ |
| 782 |
|
| 783 |
// helper routine to either |
| 784 |
// create a new TimerTableItem or |
| 785 |
// modify an existing one |
| 786 |
|
| 787 |
TimerTableItem * TimerTable::set_tableitem(TimerTableItem *item){ |
| 788 |
QDateTime start_datetime=begin_timeedit->dateTime(); |
| 789 |
QTime stop_time=end_timeedit->time(); |
| 790 |
|
| 791 |
int channel_nr=channelbox->currentItem(); |
| 792 |
|
| 793 |
QString filename=filename_edit->text(); |
| 794 |
QString desc=description_edit->text(); |
| 795 |
|
| 796 |
QString stationname=my_v4lw->getXawtvStation(channel_nr).c_str(); |
| 797 |
|
| 798 |
|
| 799 |
int when=when_combobox->currentItem(); |
| 800 |
int day=day_combobox->currentItem(); |
| 801 |
|
| 802 |
QString codec=codecbox->currentText(); |
| 803 |
|
| 804 |
QDateTime currentdatetime=QDateTime::currentDateTime(); |
| 805 |
QDate currentdate=QDate::currentDate(); |
| 806 |
QTime currenttime=currentdatetime.time(); |
| 807 |
QTime start_time=start_datetime.time(); |
| 808 |
|
| 809 |
//QString start_timestr=start_datetime.toString(my_dateformat); |
| 810 |
//QString stop_timestr=stop_time.toString(my_timeformat); |
| 811 |
|
| 812 |
|
| 813 |
if(item!=NULL){ |
| 814 |
item->setTable(channel_nr,start_datetime,stop_time,filename,desc,when,day,codec); |
| 815 |
AVMOUT(AVML_DEBUG, "Modified item %s from %s to %s", |
| 816 |
desc.latin1(),start_datetime.toString().latin1(), |
| 817 |
stop_time.toString().latin1()); |
| 818 |
} |
| 819 |
else{ |
| 820 |
item=new TimerTableItem(table,this,my_v4lw,channel_nr,start_datetime,stop_time,filename,desc,when,day,codec); |
| 821 |
AVMOUT(AVML_DEBUG, "New item %s from %s to %s", |
| 822 |
desc.latin1(),start_datetime.toString().latin1(), |
| 823 |
stop_time.toString().latin1()); |
| 824 |
} |
| 825 |
table->sort(); |
| 826 |
table->ensureItemVisible(item); |
| 827 |
|
| 828 |
return item; |
| 829 |
} |
| 830 |
|
| 831 |
/* **************************************** */ |
| 832 |
|
| 833 |
void TimerTable::button_modify_pressed(){ |
| 834 |
// TimerTableItem *item=(TimerTableItem *)table->currentItem(); |
| 835 |
|
| 836 |
TimerTableItem *item=last_item_clicked; |
| 837 |
|
| 838 |
if(item!=NULL){ |
| 839 |
AVMOUT(AVML_DEBUG, "Item modified"); |
| 840 |
set_tableitem(item); |
| 841 |
} |
| 842 |
|
| 843 |
save(); |
| 844 |
|
| 845 |
emit timertableChanged(); |
| 846 |
} |
| 847 |
|
| 848 |
/* **************************************** */ |
| 849 |
|
| 850 |
void TimerTable::button_remove_pressed(){ |
| 851 |
TimerTableItem *item=(TimerTableItem *)table->currentItem(); |
| 852 |
|
| 853 |
if (item==current_recording){ |
| 854 |
AVMOUT(AVML_WARN, "Can't remove - it's the current recording"); |
| 855 |
} |
| 856 |
else{ |
| 857 |
if(item==next_recording){ |
| 858 |
next_recording=NULL; |
| 859 |
} |
| 860 |
if(item==last_item_clicked){ |
| 861 |
last_item_clicked=NULL; |
| 862 |
} |
| 863 |
table->takeItem(item); |
| 864 |
AVMOUT(AVML_DEBUG, "Removed item %s",item->getDescription().latin1()); |
| 865 |
delete item; |
| 866 |
|
| 867 |
save(); |
| 868 |
|
| 869 |
emit timertableChanged(); |
| 870 |
} |
| 871 |
} |
| 872 |
|
| 873 |
/* **************************************** */ |
| 874 |
|
| 875 |
// gives back the first recording that should be done, |
| 876 |
// starting from this time |
| 877 |
// old recordings and disabled recordings are ignored |
| 878 |
|
| 879 |
TimerTableItem *TimerTable::find_first_recording(){ |
| 880 |
TimerTableItem *item=(TimerTableItem *)table->firstChild(); |
| 881 |
|
| 882 |
QDateTime currenttime=QDateTime::currentDateTime(); |
| 883 |
QDateTime found_date=currenttime; |
| 884 |
|
| 885 |
TimerTableItem *found_item=NULL; |
| 886 |
|
| 887 |
while(item!=NULL){ |
| 888 |
if(item->isOn()){ |
| 889 |
QDateTime new_date=item->getStartTime(); |
| 890 |
|
| 891 |
if(new_date>=currenttime){ |
| 892 |
// this recordings starts in the future |
| 893 |
//if(new_date<found_date || found_date==currenttime){ |
| 894 |
if(new_date<found_date || found_item==NULL){ |
| 895 |
// if the new date is less in the future than the |
| 896 |
// previuosly found date |
| 897 |
// or if we didn;t find any yet |
| 898 |
found_date=new_date; |
| 899 |
found_item=item; |
| 900 |
//printf("we found in the future: %s %s\n",found_date.toString().latin1(),found_item->getDescription().latin1()); |
| 901 |
} |
| 902 |
} |
| 903 |
else{ |
| 904 |
// this recording starts in the past |
| 905 |
// but it might still end in the future |
| 906 |
|
| 907 |
QDateTime stop_date=item->getStopDateTime(); |
| 908 |
if(stop_date>currenttime && item!=current_recording){ |
| 909 |
//&& current_recording==NULL){ |
| 910 |
|
| 911 |
// the stop date is in the future and |
| 912 |
// it's not the current recording |
| 913 |
found_date=new_date; |
| 914 |
found_item=item; |
| 915 |
//printf("we found at present: %s %s\n",found_date.toString().latin1(),found_item->getDescription().latin1()); |
| 916 |
} |
| 917 |
else{ |
| 918 |
// no, it also ended in the past |
| 919 |
|
| 920 |
//make sure that items in the past can never be enabled |
| 921 |
item->setOn(false); |
| 922 |
} |
| 923 |
}//end else newdate>=currenttime |
| 924 |
}//end if item(ison) |
| 925 |
|
| 926 |
if(item!=current_recording && item->getStopDateTime()<currenttime){ |
| 927 |
item->checkWhen(); |
| 928 |
table->sort(); |
| 929 |
} |
| 930 |
|
| 931 |
item=(TimerTableItem *)item->nextSibling(); |
| 932 |
} |
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
return found_item; |
| 937 |
} |
| 938 |
|
| 939 |
/* **************************************** */ |
| 940 |
|
| 941 |
// helper routine |
| 942 |
// gets called when user presses 'start timer' |
| 943 |
// or by automatic 'avicap -timer' |
| 944 |
|
| 945 |
void TimerTable::startTimer(bool set_shutdown){ |
| 946 |
if (set_shutdown) { |
| 947 |
//we have been started automatically |
| 948 |
AVMOUT(AVML_DEBUG, "Timertable started with -timer"); |
| 949 |
#if 0 |
| 950 |
int fd=open(WATCHDOG_TIMERTABLE,O_WRONLY|O_CREAT); |
| 951 |
if (fd==-1) { |
| 952 |
AVMOUT(AVM_WARNNO, "Can't create watchdog file"); |
| 953 |
} |
| 954 |
else{ |
| 955 |
char wbuf[100]; |
| 956 |
strcpy(wbuf,"ok\n"); |
| 957 |
write(fd,wbuf,strlen(wbuf)); |
| 958 |
} |
| 959 |
#endif |
| 960 |
shutdown_checkbox->setChecked(true); |
| 961 |
} |
| 962 |
|
| 963 |
if(table->childCount()>0){ |
| 964 |
|
| 965 |
TimerTableItem *first_item=find_first_recording(); |
| 966 |
|
| 967 |
if(first_item!=NULL){ |
| 968 |
next_recording=first_item; |
| 969 |
|
| 970 |
timer_mode=TimerWaiting; |
| 971 |
rec_start_button->setText("Stop Timer"); |
| 972 |
} |
| 973 |
} |
| 974 |
else{ |
| 975 |
printf("no programs, timer not started\n"); |
| 976 |
} |
| 977 |
|
| 978 |
} |
| 979 |
|
| 980 |
/* **************************************** */ |
| 981 |
|
| 982 |
void TimerTable::button_start_pressed(){ |
| 983 |
save(); |
| 984 |
|
| 985 |
if(timer_mode==TimerOff){ |
| 986 |
AVMOUT(AVML_DEBUG, "Started timer"); |
| 987 |
startTimer(false); |
| 988 |
} |
| 989 |
else if(timer_mode==TimerRecording){ |
| 990 |
AVMOUT(AVML_WARN, "Can't switch off timer while recording with timer"); |
| 991 |
} |
| 992 |
else if(timer_mode==TimerWaiting){ |
| 993 |
timer_mode=TimerOff; |
| 994 |
rec_start_button->setText(tr("Start Timer")); |
| 995 |
next_recording=NULL; |
| 996 |
AVMOUT(AVML_DEBUG, "Stopped timer"); |
| 997 |
} |
| 998 |
set_status_label(); |
| 999 |
} |
| 1000 |
|
| 1001 |
int find_keepfree(QString dirname){ |
| 1002 |
int i=0; |
| 1003 |
QString regname; |
| 1004 |
QString fullname; |
| 1005 |
|
| 1006 |
regname=QString().sprintf("DirPool-%02d-Path",i); |
| 1007 |
QString path=RS(regname,"NONE"); |
| 1008 |
|
| 1009 |
while(path!="NONE"){ |
| 1010 |
regname=QString().sprintf("DirPool-%02d-Active",i); |
| 1011 |
int act=RI(regname,1); |
| 1012 |
if(act){ |
| 1013 |
regname=QString().sprintf("DirPool-%02d-KeepFree",i); |
| 1014 |
int keepfree=RI(regname,500); |
| 1015 |
|
| 1016 |
if(path==dirname){ |
| 1017 |
return keepfree; |
| 1018 |
} |
| 1019 |
} |
| 1020 |
|
| 1021 |
i++; |
| 1022 |
|
| 1023 |
regname=QString().sprintf("DirPool-%02d-Path",i); |
| 1024 |
path=RS(regname,"NONE"); |
| 1025 |
|
| 1026 |
} |
| 1027 |
return 0; |
| 1028 |
} |
| 1029 |
|
| 1030 |
QString find_best_dir(){ |
| 1031 |
|
| 1032 |
int i=0; |
| 1033 |
QString regname; |
| 1034 |
QString fullname; |
| 1035 |
|
| 1036 |
regname=QString().sprintf("DirPool-%02d-Path",i); |
| 1037 |
QString path=RS(regname,"NONE"); |
| 1038 |
long found_free_space=0; |
| 1039 |
QString found_path; |
| 1040 |
|
| 1041 |
while(path!="NONE"){ |
| 1042 |
regname=QString().sprintf("DirPool-%02d-Active",i); |
| 1043 |
int act=RI(regname,1); |
| 1044 |
|
| 1045 |
regname=QString().sprintf("DirPool-%02d-KeepFree",i); |
| 1046 |
int keepfree=RI(regname,500); |
| 1047 |
|
| 1048 |
//printf("path=%s active=%d keepfree=%d\n",path.latin1(),act,keepfree); |
| 1049 |
if(act){ |
| 1050 |
//evaluate |
| 1051 |
|
| 1052 |
int free_space=free_diskspace(path.latin1()); |
| 1053 |
|
| 1054 |
free_space-=keepfree; |
| 1055 |
//printf("free space for avicap %dMB on %s\n",free_space,path.latin1()); |
| 1056 |
if(free_space>found_free_space){ |
| 1057 |
//printf("found free space for avicap %dMB on %s\n",free_space,path.latin1()); |
| 1058 |
found_free_space=free_space; |
| 1059 |
found_path=path; |
| 1060 |
} |
| 1061 |
}// end of 'if act' |
| 1062 |
|
| 1063 |
i++; |
| 1064 |
|
| 1065 |
regname=QString().sprintf("DirPool-%02d-Path",i); |
| 1066 |
path=RS(regname,"NONE"); |
| 1067 |
} |
| 1068 |
|
| 1069 |
if(found_free_space<=0){ |
| 1070 |
return ""; |
| 1071 |
} |
| 1072 |
|
| 1073 |
return found_path; |
| 1074 |
} |
| 1075 |
|
| 1076 |
/* **************************************** */ |
| 1077 |
|
| 1078 |
// gets called every second |
| 1079 |
// check if the state has changed and what we've got to do next |
| 1080 |
|
| 1081 |
void TimerTable::timer(){ |
| 1082 |
static long timer_counter=0; |
| 1083 |
|
| 1084 |
if (timer_counter%60==0) |
| 1085 |
AVMOUT(AVML_DEBUG, "Timer is alive"); |
| 1086 |
|
| 1087 |
timer_counter++; |
| 1088 |
|
| 1089 |
next_recording=find_first_recording(); |
| 1090 |
|
| 1091 |
if(next_recording){ |
| 1092 |
// printf("next_recording: %s\n",next_recording->getDescription().latin1()); |
| 1093 |
} |
| 1094 |
|
| 1095 |
if (next_recording && timer_mode==TimerWaiting) { |
| 1096 |
// we have a pending recording and the timer is waiting for |
| 1097 |
// pending recordings |
| 1098 |
|
| 1099 |
// now check if it's time to start this recording |
| 1100 |
QDateTime start_time=next_recording->getStartTime(); |
| 1101 |
QDateTime currenttime=QDateTime::currentDateTime(); |
| 1102 |
int secs_to_go=currenttime.secsTo(start_time); |
| 1103 |
|
| 1104 |
int secs_in_poweroff=secs_to_go \ |
| 1105 |
- RI("ShutdownRebootTimespan",5)*60 \ |
| 1106 |
- RI("ShutdownGraceTime",3)*60; |
| 1107 |
|
| 1108 |
// if(secs_to_go<10){ |
| 1109 |
if(start_time<currenttime){ |
| 1110 |
AVMOUT(AVML_DEBUG, "Starting new recording"); |
| 1111 |
// we have to start a new pending recording |
| 1112 |
// we start recording actually 10 secs before the time |
| 1113 |
|
| 1114 |
// stop old recording if necessary |
| 1115 |
stop_current_recording(); |
| 1116 |
|
| 1117 |
my_v4lw->setXawtv(next_recording->getChannel()); |
| 1118 |
|
| 1119 |
QString savename=next_recording->getNamedCodec(); |
| 1120 |
if(savename=="-Default-"){ |
| 1121 |
savename=""; |
| 1122 |
} |
| 1123 |
//what now? |
| 1124 |
|
| 1125 |
CaptureConfig *conf=new CaptureConfig(); |
| 1126 |
conf->load(); |
| 1127 |
conf->setNamedCodec(savename.latin1()); |
| 1128 |
QString filename=next_recording->getFilename(); |
| 1129 |
conf->setFilename(filename.latin1()); |
| 1130 |
|
| 1131 |
my_v4lw->captureAVI(conf); //make the new capture window |
| 1132 |
|
| 1133 |
AviCapDialog *dialog=my_v4lw->getCaptureDialog(); |
| 1134 |
|
| 1135 |
if(dialog!=NULL){ |
| 1136 |
dialog->start(); // run the thing |
| 1137 |
timer_mode=TimerRecording; |
| 1138 |
current_recording=next_recording; |
| 1139 |
} |
| 1140 |
else{ |
| 1141 |
AVMOUT(AVML_WARN, "Recording could not be started!"); |
| 1142 |
} |
| 1143 |
}// 10 secs to go |
| 1144 |
else if(secs_in_poweroff > RI("ShutdownMinTimespan",20)*60){ |
| 1145 |
// if the computer would be in off-state for the allowed time |
| 1146 |
// we check if we should do a shutdown |
| 1147 |
check_for_shutdown(); |
| 1148 |
} |
| 1149 |
} |
| 1150 |
else if(timer_mode==TimerRecording && current_recording){ |
| 1151 |
//we are currently recording |
| 1152 |
//check if we have to switch off current recording |
| 1153 |
|
| 1154 |
// check if there is still a recording actually running |
| 1155 |
// (user might have pressed stop or close) |
| 1156 |
AviCapDialog *dialog=my_v4lw->getCaptureDialog(); |
| 1157 |
CaptureProcess *capproc=NULL; |
| 1158 |
if(dialog){ |
| 1159 |
capproc=dialog->getCaptureProcess(); |
| 1160 |
} |
| 1161 |
|
| 1162 |
if(dialog==NULL || capproc==NULL){ |
| 1163 |
// no recording, so nothing to switch off |
| 1164 |
|
| 1165 |
// we disable the timertable item, so that the recording |
| 1166 |
// won't start again, or stop unwanted recordings |
| 1167 |
current_recording->setOn(false); |
| 1168 |
} |
| 1169 |
QDateTime stop_time=current_recording->getStopDateTime(); |
| 1170 |
QDateTime currenttime=QDateTime::currentDateTime(); |
| 1171 |
|
| 1172 |
//int secs_to_go=currenttime.secsTo(stop_time); |
| 1173 |
//printf("%d secs to go to stop recording\n",secs_to_go); |
| 1174 |
|
| 1175 |
if(dialog==NULL || capproc==NULL || currenttime > stop_time || \ |
| 1176 |
(next_recording && next_recording!=current_recording && next_recording->getStartTime()<currenttime)){ |
| 1177 |
// if our stop time is in the past OR |
| 1178 |
// if a next recording has been found with a stop time in the past |
| 1179 |
|
| 1180 |
// this means, a programmed recording that clashes with a second |
| 1181 |
// programmed recording will get stopped and the second one |
| 1182 |
// started |
| 1183 |
// it's your own fault if there are 'insane' recordings |
| 1184 |
// have a look at the sanity check more often ;-) |
| 1185 |
|
| 1186 |
//stop current recording, if there is |
| 1187 |
stop_current_recording(); |
| 1188 |
// we go back to wait for pending recordings |
| 1189 |
current_recording=NULL; |
| 1190 |
timer_mode=TimerWaiting; |
| 1191 |
AVMOUT(AVML_DEBUG, "Stopped current recording"); |
| 1192 |
} |
| 1193 |
} |
| 1194 |
else if(timer_mode==TimerWaiting && next_recording==NULL && current_recording==NULL){ |
| 1195 |
// no more recordings, can we shutdown? |
| 1196 |
|
| 1197 |
check_for_shutdown(); |
| 1198 |
} |
| 1199 |
|
| 1200 |
set_status_label(); |
| 1201 |
|
| 1202 |
table->repaint(); |
| 1203 |
QListViewItem *item=table->firstChild(); |
| 1204 |
while(item!=NULL){ |
| 1205 |
table->repaintItem(item); |
| 1206 |
item=item->nextSibling(); |
| 1207 |
} |
| 1208 |
|
| 1209 |
if (last_current_recording!=current_recording) { |
| 1210 |
emit currentRecordingChanged(current_recording); |
| 1211 |
AVMOUT(AVML_DEBUG, "Current recording changed"); |
| 1212 |
} |
| 1213 |
if (last_next_recording!=next_recording) { |
| 1214 |
emit nextRecordingChanged(next_recording); |
| 1215 |
AVMOUT(AVML_DEBUG, "Next recording changed"); |
| 1216 |
} |
| 1217 |
last_current_recording=current_recording; |
| 1218 |
last_next_recording=next_recording; |
| 1219 |
} |
| 1220 |
|
| 1221 |
/* **************************************** */ |
| 1222 |
|
| 1223 |
void TimerTable::check_for_shutdown(){ |
| 1224 |
|
| 1225 |
int shutdown_mode=RI("ShutdownMode",0); |
| 1226 |
if(shutdown_mode==0){ |
| 1227 |
// never shut down |
| 1228 |
return; |
| 1229 |
} |
| 1230 |
|
| 1231 |
bool shutdown=shutdown_checkbox->isChecked(); |
| 1232 |
|
| 1233 |
if(shutdown){ |
| 1234 |
if(!shutdown_message){ |
| 1235 |
// open up a new message |
| 1236 |
AVMOUT(AVML_DEBUG, "Shutdown procedure started"); |
| 1237 |
shutdown_message=new QMessageBox( tr( "AviCap Shutdown warning" ), |
| 1238 |
"System is going to shutdown\n\nin some seconds\n", |
| 1239 |
QMessageBox::Critical,QMessageBox::Abort, |
| 1240 |
QMessageBox::NoButton,QMessageBox::NoButton,this); |
| 1241 |
shutdown_message->show(); |
| 1242 |
shutdown_time=QDateTime::currentDateTime(); |
| 1243 |
shutdown_time=shutdown_time.addSecs(RI("ShutdownGraceTime",3)*60); |
| 1244 |
} |
| 1245 |
else{ |
| 1246 |
// there is already a shutdown message open |
| 1247 |
|
| 1248 |
QDateTime currenttime=QDateTime::currentDateTime(); |
| 1249 |
int secsto=currenttime.secsTo(shutdown_time); |
| 1250 |
AVMOUT(AVML_DEBUG, "Secs to shutdown: %d res=%d", |
| 1251 |
secsto,shutdown_message->result()); |
| 1252 |
if(shutdown_message->result()==5){ |
| 1253 |
AVMOUT(AVML_DEBUG, "Shutdown aborted by user"); |
| 1254 |
// the user has aborted shutdown |
| 1255 |
delete shutdown_message; |
| 1256 |
shutdown_message=NULL; |
| 1257 |
shutdown_checkbox->setChecked(0); |
| 1258 |
} |
| 1259 |
else if (secsto>0) |
| 1260 |
{ |
| 1261 |
// we still have grace time before shutdown |
| 1262 |
char buf[300]; |
| 1263 |
sprintf(buf,"System is going to shutdown\n\n in %d seconds\n",secsto); |
| 1264 |
shutdown_message->setText(buf); |
| 1265 |
shutdown_message->show(); |
| 1266 |
} |
| 1267 |
else |
| 1268 |
{ |
| 1269 |
// it's time to do the shutdown |
| 1270 |
AVMOUT(AVML_DEBUG, "shutdown T=0 secs"); |
| 1271 |
save(); |
| 1272 |
|
| 1273 |
sleep(5); |
| 1274 |
|
| 1275 |
if(shutdown_mode==2){ |
| 1276 |
// with nvram-wakeup |
| 1277 |
long timestamp=0; |
| 1278 |
|
| 1279 |
if(next_recording){ |
| 1280 |
QDateTime nextdate=next_recording->getStartTime(); |
| 1281 |
|
| 1282 |
//int timediff=calcTimeDiff(nextdate); |
| 1283 |
|
| 1284 |
// argl - you cant get a timestamp from a QDateTime |
| 1285 |
// we have to calculate it ourselves |
| 1286 |
QDateTime bigbang=QDateTime(); |
| 1287 |
bigbang.setTime_t(0); |
| 1288 |
timestamp=bigbang.secsTo(nextdate); |
| 1289 |
|
| 1290 |
// check if system is running localtime different from UTC |
| 1291 |
QDateTime checktime=QDateTime(); |
| 1292 |
checktime.setTime_t(timestamp); |
| 1293 |
long timestamp2=bigbang.secsTo(checktime); |
| 1294 |
// if timediff!=0, we're in localtime |
| 1295 |
int timediff=timestamp-timestamp2; |
| 1296 |
// I have no idea if this works on systems that their hw/rtc/system-clock with UTC |
| 1297 |
|
| 1298 |
AVMOUT(AVML_DEBUG, |
| 1299 |
"timestamp=%ld timestamp2=%ld diffsecs=%d diffmin=%d nextdate=%s bigbang=%s checktime=%s", |
| 1300 |
timestamp,timestamp2,timediff,timediff/60, |
| 1301 |
nextdate.toString(my_dateformat).latin1(), |
| 1302 |
bigbang.toString(my_dateformat).latin1(), |
| 1303 |
checktime.toString(my_dateformat).latin1()); |
| 1304 |
|
| 1305 |
timestamp+=timediff; |
| 1306 |
timestamp-=RI("ShutdownRebootTimespan",5)*60; |
| 1307 |
|
| 1308 |
QDateTime reboot_time=QDateTime(); |
| 1309 |
reboot_time.setTime_t(timestamp); |
| 1310 |
|
| 1311 |
AVMOUT(AVML_DEBUG, "system will reboot at timestamp %ld (%s)", |
| 1312 |
timestamp, reboot_time.toString(my_dateformat).latin1()); |
| 1313 |
// printf( |
| 1314 |
}//end of 'we have a next recording' |
| 1315 |
|
| 1316 |
// set nvram timer with nvram-wakeup |
| 1317 |
// if no next recording, timestamp wil be 0 |
| 1318 |
// and nvram-setup will disable RTC alarm wakeup |
| 1319 |
|
| 1320 |
AVMOUT(AVML_DEBUG, "Setting nvram"); |
| 1321 |
char cbuf[300]; |
| 1322 |
sprintf(cbuf,"sudo avicap-setnvram %ld",timestamp); |
| 1323 |
system(cbuf); |
| 1324 |
|
| 1325 |
sleep(10); |
| 1326 |
}// end of 'shutdown mode 2' |
| 1327 |
|
| 1328 |
// we do this in shutdown mode 1 and 2 |
| 1329 |
|
| 1330 |
// SHUTDOWN NOW |
| 1331 |
|
| 1332 |
system("sudo avicap-shutdown &"); |
| 1333 |
|
| 1334 |
//exit avicap |
| 1335 |
exit(0); |
| 1336 |
}// end of 'its time do shutdown now' |
| 1337 |
}// end of 'we have shutdown message open' |
| 1338 |
}// end of 'shutdown is checked' |
| 1339 |
} |
| 1340 |
|
| 1341 |
/* **************************************** */ |
| 1342 |
|
| 1343 |
void TimerTable::stop_current_recording(){ |
| 1344 |
// stop old recording |
| 1345 |
AviCapDialog *dialog_old=my_v4lw->getCaptureDialog(); |
| 1346 |
if(dialog_old!=NULL){ |
| 1347 |
// there is a recording dialog open |
| 1348 |
|
| 1349 |
CaptureProcess *capproc=dialog_old->getCaptureProcess(); |
| 1350 |
|
| 1351 |
if(capproc!=NULL){ |
| 1352 |
// there's a recording running |
| 1353 |
AVMOUT(AVML_DEBUG, "Current recording has been stopped"); |
| 1354 |
dialog_old->stop(); |
| 1355 |
dialog_old->close(); |
| 1356 |
} |
| 1357 |
} |
| 1358 |
// the dialog itself doesn't get closed |
| 1359 |
|
| 1360 |
//reset the codec |
| 1361 |
// global_savename=RS("NamedCodecsCurrent","-Default-"); |
| 1362 |
} |
| 1363 |
|
| 1364 |
/* **************************************** */ |
| 1365 |
|
| 1366 |
// helper routine to calc the stop DateTime from the given |
| 1367 |
// start DateTime and stop Time |
| 1368 |
|
| 1369 |
QDateTime TimerTable::calc_stopDateTime(QDateTime start_datetime,QTime stop_time){ |
| 1370 |
QTime start_time=start_datetime.time(); |
| 1371 |
QDate start_date=start_datetime.date(); |
| 1372 |
|
| 1373 |
QDateTime stop_datetime(start_date,stop_time); |
| 1374 |
|
| 1375 |
if(start_time > stop_time ){ |
| 1376 |
// the recording ends the next day |
| 1377 |
stop_datetime=stop_datetime.addDays(1); |
| 1378 |
} |
| 1379 |
|
| 1380 |
return stop_datetime; |
| 1381 |
} |
| 1382 |
|
| 1383 |
/* **************************************** */ |
| 1384 |
|
| 1385 |
// loads settings from registry |
| 1386 |
|
| 1387 |
void TimerTable::load(){ |
| 1388 |
int i=0; |
| 1389 |
char buf[300]; |
| 1390 |
|
| 1391 |
// QDateTime currenttime= |
| 1392 |
|
| 1393 |
sprintf(buf,"TT-%02d-StartTime",i); |
| 1394 |
avm::string starttimestr=RS(buf,"NONE"); |
| 1395 |
|
| 1396 |
while(starttimestr!="NONE"){ |
| 1397 |
|
| 1398 |
sprintf(buf,"TT-%02d-StopTime",i); |
| 1399 |
avm::string stoptimestr=RS(buf,"NONE"); |
| 1400 |
|
| 1401 |
QDateTime starttime; |
| 1402 |
QTime stoptime; |
| 1403 |
|
| 1404 |
//starttime=QDateTime::fromString(starttimestr.c_str()); |
| 1405 |
//stoptime=QTime::fromString(stoptimestr.c_str()); |
| 1406 |
|
| 1407 |
starttime=dateTimeFromString(starttimestr.c_str()); |
| 1408 |
stoptime=dateTimeFromString(stoptimestr.c_str()).time(); |
| 1409 |
|
| 1410 |
|
| 1411 |
|
| 1412 |
sprintf(buf,"TT-%02d-Channel",i); |
| 1413 |
int channel=RI(buf,0); |
| 1414 |
|
| 1415 |
sprintf(buf,"TT-%02d-When",i); |
| 1416 |
int when=RI(buf,0); |
| 1417 |
|
| 1418 |
sprintf(buf,"TT-%02d-WhenDay",i); |
| 1419 |
int day=RI(buf,0); |
| 1420 |
|
| 1421 |
sprintf(buf,"TT-%02d-Filename",i); |
| 1422 |
avm::string filename=RS(buf,"./movie.avi"); |
| 1423 |
|
| 1424 |
sprintf(buf,"TT-%02d-Description",i); |
| 1425 |
avm::string desc=RS(buf,"untitled"); |
| 1426 |
|
| 1427 |
sprintf(buf,"TT-%02d-NamedCodec",i); |
| 1428 |
avm::string codec=RS(buf,"-Default-"); |
| 1429 |
|
| 1430 |
TimerTableItem *item; |
| 1431 |
item=new TimerTableItem(table,this,my_v4lw,channel,starttime,stoptime,QString(filename.c_str()),QString(desc.c_str()),when,day,QString(codec.c_str())); |
| 1432 |
|
| 1433 |
|
| 1434 |
sprintf(buf,"TT-%02d-Active",i); |
| 1435 |
int ison=RI(buf,1); |
| 1436 |
|
| 1437 |
item->setOn(ison); |
| 1438 |
|
| 1439 |
i++; |
| 1440 |
|
| 1441 |
sprintf(buf,"TT-%02d-StartTime",i); |
| 1442 |
starttimestr=RS(buf,"NONE"); |
| 1443 |
} |
| 1444 |
} |
| 1445 |
|
| 1446 |
/* **************************************** */ |
| 1447 |
|
| 1448 |
// saves settings into registry |
| 1449 |
|
| 1450 |
void TimerTable::save(){ |
| 1451 |
int i=0; |
| 1452 |
char buf[200]; |
| 1453 |
|
| 1454 |
TimerTableItem *item=(TimerTableItem *)table->firstChild(); |
| 1455 |
|
| 1456 |
while(item!=NULL){ |
| 1457 |
sprintf(buf,"TT-%02d-StartTime",i); |
| 1458 |
//WS(buf,item->getStartTime().toString(my_dateformat).latin1()); |
| 1459 |
//WS(buf,item->getStartTime().toString().latin1()); |
| 1460 |
WS(buf,dateTimeToString(item->getStartTime())); |
| 1461 |
sprintf(buf,"TT-%02d-StopTime",i); |
| 1462 |
WS(buf,dateTimeToString(item->getStopDateTime())); |
| 1463 |
|
| 1464 |
sprintf(buf,"TT-%02d-Channel",i); |
| 1465 |
WI(buf,item->getChannel()); |
| 1466 |
|
| 1467 |
sprintf(buf,"TT-%02d-When",i); |
| 1468 |
WI(buf,item->getWhen()); |
| 1469 |
|
| 1470 |
sprintf(buf,"TT-%02d-WhenDay",i); |
| 1471 |
WI(buf,item->getDay()); |
| 1472 |
|
| 1473 |
sprintf(buf,"TT-%02d-Filename",i); |
| 1474 |
WS(buf,item->getFilename().latin1()); |
| 1475 |
|
| 1476 |
sprintf(buf,"TT-%02d-Description",i); |
| 1477 |
WS(buf,item->getDescription().latin1()); |
| 1478 |
|
| 1479 |
sprintf(buf,"TT-%02d-NamedCodec",i); |
| 1480 |
WS(buf,item->getNamedCodec().latin1()); |
| 1481 |
|
| 1482 |
sprintf(buf,"TT-%02d-Active",i); |
| 1483 |
WI(buf,item->isOn()); |
| 1484 |
|
| 1485 |
item=(TimerTableItem *)item->nextSibling(); |
| 1486 |
i++; |
| 1487 |
} |
| 1488 |
|
| 1489 |
// make sure that's the last one... |
| 1490 |
|
| 1491 |
sprintf(buf,"TT-%02d-StartTime",i); |
| 1492 |
WS(buf,"NONE"); |
| 1493 |
|
| 1494 |
// actually save to file |
| 1495 |
avm::RegSave(); |
| 1496 |
AVMOUT(AVML_DEBUG, "Registry saved to file"); |
| 1497 |
} |
| 1498 |
|
| 1499 |
int free_diskspace(avm::string path){ |
| 1500 |
int free_space=0; |
| 1501 |
|
| 1502 |
struct statfs statbuf; |
| 1503 |
int res=statfs(path.c_str(),&statbuf); |
| 1504 |
if(res==-1){ |
| 1505 |
printf("cannot statfs: %s\n",path.c_str()); |
| 1506 |
free_space=0; |
| 1507 |
} |
| 1508 |
else{ |
| 1509 |
double long free_bytes=statbuf.f_bsize*statbuf.f_bavail; |
| 1510 |
free_space=(int)(free_bytes/(1024*1024)); |
| 1511 |
} |
| 1512 |
|
| 1513 |
return free_space; |
| 1514 |
} |
| 1515 |
|
| 1516 |
QString dateTimeToString(QDateTime dt) |
| 1517 |
{ |
| 1518 |
QString str; |
| 1519 |
int year=dt.date().year(); |
| 1520 |
int month=dt.date().month(); |
| 1521 |
int day=dt.date().day(); |
| 1522 |
|
| 1523 |
str=QString().sprintf("%04d-%02d-%02d/",year,month,day)+dt.time().toString(); |
| 1524 |
|
| 1525 |
return str; |
| 1526 |
} |
| 1527 |
|
| 1528 |
QDateTime dateTimeFromString(QString datestr) |
| 1529 |
{ |
| 1530 |
// str has to be like this: 2003-04-06/18:14:11 |
| 1531 |
QString yearstr=datestr.mid(0,4); |
| 1532 |
QString monstr=datestr.mid(5,2); |
| 1533 |
QString daystr=datestr.mid(8,2); |
| 1534 |
|
| 1535 |
QString hourstr=datestr.mid(11,2); |
| 1536 |
QString minstr=datestr.mid(14,2); |
| 1537 |
QString secstr=datestr.mid(17,2); |
| 1538 |
|
| 1539 |
QDateTime datetime; |
| 1540 |
|
| 1541 |
datetime.setDate(QDate(yearstr.toInt(),monstr.toInt(),daystr.toInt())); |
| 1542 |
datetime.setTime(QTime(hourstr.toInt(),minstr.toInt(),secstr.toInt())); |
| 1543 |
|
| 1544 |
// printf("strings %s %s %s %s %s %s\n", |
| 1545 |
// yearstr.latin1(),monstr.latin1(),daystr.latin1(), |
| 1546 |
// hourstr.latin1(),minstr.latin1(),secstr.latin1()); |
| 1547 |
|
| 1548 |
//printf("parsed %s to %s\n",datestr.latin1(),datetime.toString().latin1()); |
| 1549 |
return datetime; |
| 1550 |
} |
| 1551 |
|
| 1552 |
#if QT_VERSION<300 |
| 1553 |
|
| 1554 |
ADateTimeEdit::ADateTimeEdit(QWidget *w,QString name) : QLineEdit(w) |
| 1555 |
{ |
| 1556 |
datetime=QDateTime::currentDateTime(); |
| 1557 |
} |
| 1558 |
|
| 1559 |
void ADateTimeEdit::updateFromWidget() |
| 1560 |
{ |
| 1561 |
QString wstr=text(); |
| 1562 |
datetime=dateTimeFromString(wstr); |
| 1563 |
} |
| 1564 |
|
| 1565 |
QString ADateTimeEdit::toString(QDateTime dt) |
| 1566 |
{ |
| 1567 |
return dateTimeToString(dt); |
| 1568 |
|
| 1569 |
} |
| 1570 |
|
| 1571 |
void ADateTimeEdit::setTime(QTime newtime) |
| 1572 |
{ |
| 1573 |
datetime.setTime(newtime); |
| 1574 |
setText(toString(datetime)); |
| 1575 |
} |
| 1576 |
|
| 1577 |
void ADateTimeEdit::setDateTime(QDateTime newdatetime) |
| 1578 |
{ |
| 1579 |
datetime=newdatetime; |
| 1580 |
QString helper=toString(datetime); |
| 1581 |
setText(helper); |
| 1582 |
} |
| 1583 |
|
| 1584 |
#endif |