00001 #include <cstdlib>
00002
00003 #include <qdir.h>
00004 #include <qapplication.h>
00005 #include <qfileinfo.h>
00006 #include <qsqldatabase.h>
00007
00008
00009 #include <mythtv/mythcontext.h>
00010 #include <mythtv/mythdbcon.h>
00011 #include <mythtv/uitypes.h>
00012
00013
00014 #include "importnativewizard.h"
00015 #include "archiveutil.h"
00016
00017
00018 const int LAST_PAGE = 2;
00019
00021
00022 ImportNativeWizard::ImportNativeWizard(const QString &startDir,
00023 const QString &filemask, MythMainWindow *parent,
00024 const QString &window_name, const QString &theme_filename,
00025 const char *name)
00026 :MythThemedDialog(parent, window_name, theme_filename, name)
00027 {
00028 setContext(1);
00029 m_filemask = filemask;
00030 m_curDirectory = startDir;
00031 m_isValidXMLSelected = false;
00032 wireUpTheme();
00033 }
00034
00035 ImportNativeWizard::~ImportNativeWizard()
00036 {
00037 }
00038
00039 void ImportNativeWizard::keyPressEvent(QKeyEvent *e)
00040 {
00041 bool handled = false;
00042
00043 QStringList actions;
00044 gContext->GetMainWindow()->TranslateKeyPress("Global", e, actions);
00045
00046 for (unsigned int i = 0; i < actions.size() && !handled; i++)
00047 {
00048 QString action = actions[i];
00049 handled = true;
00050
00051 if (action == "SELECT")
00052 {
00053 if (getCurrentFocusWidget() == m_fileList)
00054 {
00055 UIListBtnTypeItem *item = m_fileList->GetItemCurrent();
00056 FileInfo *fileData = (FileInfo*)item->getData();
00057
00058 if (fileData->directory)
00059 {
00060 if (fileData->filename == "..")
00061 {
00062
00063 int pos = m_curDirectory.findRev('/');
00064 if (pos > 0)
00065 m_curDirectory = m_curDirectory.left(pos);
00066 else
00067 m_curDirectory = "/";
00068 }
00069 else
00070 {
00071 if (!m_curDirectory.endsWith("/"))
00072 m_curDirectory += "/";
00073 m_curDirectory += fileData->filename;
00074 }
00075 updateFileList();
00076 }
00077 else
00078 {
00079 QString fullPath = m_curDirectory;
00080 if (!fullPath.endsWith("/"))
00081 fullPath += "/";
00082 fullPath += fileData->filename;
00083
00084 if (item->state() == UIListBtnTypeItem::FullChecked)
00085 {
00086 m_selectedList.remove(fullPath);
00087 item->setChecked(UIListBtnTypeItem::NotChecked);
00088 }
00089 else
00090 {
00091 if (m_selectedList.findIndex(fullPath) == -1)
00092 m_selectedList.append(fullPath);
00093 item->setChecked(UIListBtnTypeItem::FullChecked);
00094 }
00095
00096 m_fileList->refresh();
00097 }
00098 }
00099 else
00100 activateCurrent();
00101 }
00102 else if (action == "PAUSE")
00103 {
00104 }
00105 else if (action == "UP")
00106 {
00107 if (getCurrentFocusWidget() == m_fileList)
00108 {
00109 m_fileList->MoveUp(UIListBtnType::MoveItem);
00110 m_fileList->refresh();
00111 }
00112 else
00113 nextPrevWidgetFocus(false);
00114 }
00115 else if (action == "DOWN")
00116 {
00117 if (getCurrentFocusWidget() == m_fileList)
00118 {
00119 m_fileList->MoveDown(UIListBtnType::MoveItem);
00120 m_fileList->refresh();
00121 }
00122 else
00123 nextPrevWidgetFocus(true);
00124 }
00125 else if (action == "LEFT")
00126 {
00127 nextPrevWidgetFocus(false);
00128 }
00129 else if (action == "RIGHT")
00130 {
00131 nextPrevWidgetFocus(true);
00132 }
00133 else if (action == "PAGEUP")
00134 {
00135 if (getCurrentFocusWidget() == m_fileList)
00136 {
00137 m_fileList->MoveUp(UIListBtnType::MovePage);
00138 m_fileList->refresh();
00139 }
00140 }
00141 else if (action == "PAGEDOWN")
00142 {
00143 if (getCurrentFocusWidget() == m_fileList)
00144 {
00145 m_fileList->MoveDown(UIListBtnType::MovePage);
00146 m_fileList->refresh();
00147 }
00148 }
00149 else
00150 handled = false;
00151 }
00152
00153 if (!handled)
00154 MythThemedDialog::keyPressEvent(e);
00155 }
00156
00157 void ImportNativeWizard::wireUpTheme()
00158 {
00159 m_fileList = getUIListBtnType("filelist");
00160 if (m_fileList)
00161 {
00162 connect(m_fileList, SIGNAL(itemSelected(UIListBtnTypeItem *)),
00163 this, SLOT(selectedChanged(UIListBtnTypeItem *)));
00164 }
00165
00166 m_locationEdit = getUIRemoteEditType("location_edit");
00167 if (m_locationEdit)
00168 {
00169 m_locationEdit->createEdit(this);
00170 connect(m_locationEdit, SIGNAL(loosingFocus()),
00171 this, SLOT(locationEditLostFocus()));
00172 }
00173
00174
00175 m_backButton = getUITextButtonType("back_button");
00176 if (m_backButton)
00177 {
00178 m_backButton->setText(tr("Back"));
00179 connect(m_backButton, SIGNAL(pushed()), this, SLOT(backPressed()));
00180 }
00181
00182
00183 m_homeButton = getUITextButtonType("home_button");
00184 if (m_homeButton)
00185 {
00186 m_homeButton->setText(tr("Home"));
00187 connect(m_homeButton, SIGNAL(pushed()), this, SLOT(homePressed()));
00188 }
00189
00190 m_title_text = getUITextType("title_text");
00191 m_subtitle_text = getUITextType("subtitle_text");
00192 m_starttime_text = getUITextType("starttime_text");
00193
00194
00195 m_progTitle_text = getUITextType("progtitle");
00196 m_progDateTime_text = getUITextType("progdatetime");
00197 m_progDescription_text = getUITextType("progdescription");
00198
00199 m_chanID_text = getUITextType("chanid");
00200 m_chanNo_text = getUITextType("channo");
00201 m_chanName_text = getUITextType("name");
00202 m_callsign_text = getUITextType("callsign");
00203
00204 m_localChanID_text = getUITextType("local_chanid");
00205 m_localChanNo_text = getUITextType("local_channo");
00206 m_localChanName_text = getUITextType("local_name");
00207 m_localCallsign_text = getUITextType("local_callsign");
00208
00209 m_searchChanID_button = getUIPushButtonType("searchchanid_button");
00210 if (m_searchChanID_button)
00211 {
00212 connect(m_searchChanID_button, SIGNAL(pushed()), this, SLOT(searchChanID()));
00213 }
00214
00215 m_searchChanNo_button = getUIPushButtonType("searchchanno_button");
00216 if (m_searchChanNo_button)
00217 {
00218 connect(m_searchChanNo_button, SIGNAL(pushed()), this, SLOT(searchChanNo()));
00219 }
00220
00221 m_searchChanName_button = getUIPushButtonType("searchname_button");
00222 if (m_searchChanName_button)
00223 {
00224 connect(m_searchChanName_button, SIGNAL(pushed()), this, SLOT(searchName()));
00225 }
00226
00227 m_searchCallsign_button = getUIPushButtonType("searchcallsign_button");
00228 if (m_searchCallsign_button)
00229 {
00230 connect(m_searchCallsign_button, SIGNAL(pushed()), this, SLOT(searchCallsign()));
00231 }
00232
00233
00234
00235 m_nextButton = getUITextButtonType("next_button");
00236 if (m_nextButton)
00237 {
00238 m_nextButton->setText(tr("Next"));
00239 connect(m_nextButton, SIGNAL(pushed()), this, SLOT(nextPressed()));
00240 }
00241
00242
00243 m_prevButton = getUITextButtonType("prev_button");
00244 if (m_prevButton)
00245 {
00246 m_prevButton->setText(tr("Previous"));
00247 connect(m_prevButton, SIGNAL(pushed()), this, SLOT(prevPressed()));
00248 }
00249
00250
00251 m_cancelButton = getUITextButtonType("cancel_button");
00252 if (m_cancelButton)
00253 {
00254 m_cancelButton->setText(tr("Cancel"));
00255 connect(m_cancelButton, SIGNAL(pushed()), this, SLOT(cancelPressed()));
00256 }
00257
00258 if (!m_fileList || !m_locationEdit || !m_backButton || !m_nextButton
00259 || !m_prevButton || !m_cancelButton || !m_homeButton)
00260 {
00261 cout << "ImportNativeWizard: Your theme is missing some UI elements! Bailing out." << endl;
00262 QTimer::singleShot(100, this, SLOT(reject()));
00263 }
00264
00265
00266 m_directoryPixmap = gContext->LoadScalePixmap("ma_folder.png");
00267
00268 buildFocusList();
00269 assignFirstFocus();
00270 updateFileList();
00271 }
00272
00273 void ImportNativeWizard::locationEditLostFocus()
00274 {
00275 m_curDirectory = m_locationEdit->getText();
00276 updateFileList();
00277 }
00278
00279 void ImportNativeWizard::backPressed()
00280 {
00281
00282 int pos = m_curDirectory.findRev('/');
00283 if (pos > 0)
00284 m_curDirectory = m_curDirectory.left(pos);
00285 else
00286 m_curDirectory = "/";
00287
00288 updateFileList();
00289 }
00290
00291 void ImportNativeWizard::homePressed()
00292 {
00293 char *home = getenv("HOME");
00294 m_curDirectory = home;
00295
00296 updateFileList();
00297 }
00298
00299 void ImportNativeWizard::nextPressed()
00300
00301 {
00302 if (getContext() == 1 && !m_isValidXMLSelected)
00303 {
00304
00305 MythPopupBox::showOkPopup(gContext->GetMainWindow(), tr("Myth Archive"),
00306 tr("You need to select a valid archive XML file!"));
00307 return;
00308 }
00309
00310 if (getContext() == LAST_PAGE)
00311 {
00312 if (m_localChanID_text->GetText() == "")
00313 {
00314
00315 MythPopupBox::showOkPopup(gContext->GetMainWindow(), tr("Myth Archive"),
00316 tr("You need to select a valid chanID!"));
00317 return;
00318 }
00319
00320 QString commandline;
00321 QString tempDir = gContext->GetSetting("MythArchiveTempDir", "");
00322 QString chanID = m_localChanID_text->GetText();
00323
00324 if (tempDir == "")
00325 return;
00326
00327 if (!tempDir.endsWith("/"))
00328 tempDir += "/";
00329
00330 QString logDir = tempDir + "logs";
00331
00332
00333 if (QFile::exists(logDir + "/progress.log"))
00334 QFile::remove(logDir + "/progress.log");
00335
00336
00337 UIListBtnTypeItem *item = m_fileList->GetItemCurrent();
00338 FileInfo *fileInfo = (FileInfo*)item->getData();
00339
00340 QString filename = m_curDirectory;
00341 if (!filename.endsWith("/"))
00342 filename += "/";
00343 filename += fileInfo->filename;
00344
00345 commandline = "mytharchivehelper -f \"" + filename + "\" " + chanID;
00346 commandline += " > " + logDir + "/progress.log 2>&1 &";
00347
00348 int state = system(commandline);
00349
00350 if (state != 0)
00351 {
00352 MythPopupBox::showOkPopup(gContext->GetMainWindow(), QObject::tr("Myth Archive"),
00353 QObject::tr("It was not possible to import the Archive. "
00354 " An error occured when running 'mytharchivehelper'") );
00355 done(Rejected);
00356 return;
00357 }
00358
00359 done(Accepted);
00360 }
00361 else
00362 setContext(getContext() + 1);
00363
00364 if (m_nextButton)
00365 {
00366 if (getContext() == LAST_PAGE)
00367 m_nextButton->setText(tr("Finish"));
00368 else
00369 m_nextButton->setText(tr("Next"));
00370 }
00371
00372 updateForeground();
00373 buildFocusList();
00374 }
00375
00376 void ImportNativeWizard::prevPressed()
00377 {
00378 if (getContext() > 1)
00379 setContext(getContext() - 1);
00380
00381 if (m_nextButton)
00382 m_nextButton->setText(tr("Next"));
00383
00384 updateForeground();
00385 buildFocusList();
00386 }
00387
00388 void ImportNativeWizard::cancelPressed()
00389 {
00390 reject();
00391 }
00392
00393 void ImportNativeWizard::updateFileList()
00394 {
00395 if (!m_fileList)
00396 return;
00397
00398 m_fileList->Reset();
00399 m_fileData.clear();
00400 QDir d;
00401
00402 d.setPath(m_curDirectory);
00403 if (d.exists())
00404 {
00405
00406 const QFileInfoList *list = d.entryInfoList("*", QDir::Dirs, QDir::Name);
00407 QFileInfoListIterator it(*list);
00408 QFileInfo *fi;
00409
00410 while ( (fi = it.current()) != 0 )
00411 {
00412 if (fi->fileName() != ".")
00413 {
00414 FileInfo *data = new FileInfo;
00415 data->selected = false;
00416 data->directory = true;
00417 data->filename = fi->fileName();
00418 data->size = 0;
00419 m_fileData.append(data);
00420
00421
00422 UIListBtnTypeItem* item = new UIListBtnTypeItem(
00423 m_fileList, data->filename);
00424 item->setCheckable(false);
00425 item->setPixmap(m_directoryPixmap);
00426 item->setData(data);
00427 }
00428 ++it;
00429 }
00430
00431
00432 list = d.entryInfoList(m_filemask, QDir::Files, QDir::Name);
00433 it = QFileInfoListIterator(*list);
00434
00435 while ( (fi = it.current()) != 0 )
00436 {
00437 FileInfo *data = new FileInfo;
00438 data->selected = false;
00439 data->directory = false;
00440 data->filename = fi->fileName();
00441 data->size = fi->size();
00442 m_fileData.append(data);
00443
00444 UIListBtnTypeItem* item = new UIListBtnTypeItem(
00445 m_fileList,
00446 data->filename + " (" + formatSize(data->size / 1024, 2) + ")");
00447
00448 item->setCheckable(false);
00449 item->setData(data);
00450
00451 ++it;
00452 }
00453 m_locationEdit->setText(m_curDirectory);
00454 }
00455 else
00456 {
00457 m_locationEdit->setText("/");
00458 cout << "MythArchive: current directory does not exist!" << endl;
00459 }
00460
00461 m_fileList->refresh();
00462 }
00463
00464 void ImportNativeWizard::selectedChanged(UIListBtnTypeItem *item)
00465 {
00466 m_isValidXMLSelected = false;
00467
00468 if (!item)
00469 return;
00470
00471 FileInfo *f;
00472
00473 f = (FileInfo *) item->getData();
00474
00475 if (!f)
00476 return;
00477
00478 if (!f->directory && f->filename.endsWith(".xml"))
00479 loadXML(m_curDirectory + "/" + f->filename);
00480 else
00481 {
00482 m_title_text->SetText("");
00483 m_subtitle_text->SetText("");
00484 m_starttime_text->SetText("");
00485 }
00486 }
00487
00488 void ImportNativeWizard::loadXML(const QString &filename)
00489 {
00490 QDomDocument doc("mydocument");
00491 QFile file(filename);
00492 if (!file.open(IO_ReadOnly))
00493 return;
00494
00495 if (!doc.setContent( &file ))
00496 {
00497 file.close();
00498 return;
00499 }
00500 file.close();
00501
00502 QString docType = doc.doctype().name();
00503
00504 if (docType == "MYTHARCHIVEITEM")
00505 {
00506 QDomNodeList itemNodeList = doc.elementsByTagName("item");
00507 QString type, dbVersion;
00508
00509 if (itemNodeList.count() < 1)
00510 {
00511 cout << "Couldn't find an 'item' element in XML file" << endl;
00512 return;
00513 }
00514
00515 QDomNode n = itemNodeList.item(0);
00516 QDomElement e = n.toElement();
00517 type = e.attribute("type");
00518 dbVersion = e.attribute("databaseversion");
00519 if (type == "recording")
00520 {
00521 QDomNodeList nodeList = e.elementsByTagName("recorded");
00522 if (nodeList.count() < 1)
00523 {
00524 cout << "Couldn't find a 'recorded' element in XML file" << endl;
00525 return;
00526 }
00527
00528 n = nodeList.item(0);
00529 e = n.toElement();
00530 n = e.firstChild();
00531 while (!n.isNull())
00532 {
00533 e = n.toElement();
00534 if (!e.isNull())
00535 {
00536 if (e.tagName() == "title")
00537 {
00538 m_title_text->SetText(e.text());
00539 m_progTitle_text->SetText(e.text());
00540 }
00541
00542 if (e.tagName() == "subtitle")
00543 m_subtitle_text->SetText(e.text());
00544
00545 if (e.tagName() == "starttime")
00546 {
00547 QDateTime startTime = QDateTime::fromString(e.text(), Qt::ISODate);
00548 QString dateFormat = gContext->GetSetting("DateFormat", "ddd MMMM d");
00549 QString timeFormat = gContext->GetSetting("TimeFormat", "h:mm AP");
00550 m_starttime_text->SetText(startTime.toString(
00551 dateFormat + " " + timeFormat));
00552 m_progDateTime_text->SetText(startTime.toString("dd MMM yy (hh:mm)"));
00553 }
00554
00555 if (e.tagName() == "description")
00556 {
00557 m_progDescription_text->SetText(
00558 (m_subtitle_text->GetText() != "" ?
00559 m_subtitle_text->GetText() + "\n" : "") + e.text());
00560 }
00561 }
00562 n = n.nextSibling();
00563 }
00564
00565
00566 n = itemNodeList.item(0);
00567 e = n.toElement();
00568 nodeList = e.elementsByTagName("channel");
00569 if (nodeList.count() < 1)
00570 {
00571 cout << "Couldn't find a 'channel' element in XML file" << endl;
00572 m_chanID_text->SetText("");
00573 m_chanNo_text->SetText("");
00574 m_chanName_text->SetText("");
00575 m_callsign_text->SetText("");
00576 return;
00577 }
00578
00579 n = nodeList.item(0);
00580 e = n.toElement();
00581 m_chanID_text->SetText(e.attribute("chanid"));
00582 m_chanNo_text->SetText(e.attribute("channum"));
00583 m_chanName_text->SetText(e.attribute("name"));
00584 m_callsign_text->SetText(e.attribute("callsign"));
00585 findChannelMatch(e.attribute("chanid"), e.attribute("channum"),
00586 e.attribute("name"), e.attribute("callsign"));
00587
00588 m_isValidXMLSelected = true;
00589 }
00590 else if (type == "video")
00591 {
00592 QDomNodeList nodeList = e.elementsByTagName("videometadata");
00593 if (nodeList.count() < 1)
00594 {
00595 cout << "Couldn't find a 'videometadata' element in XML file" << endl;
00596 return;
00597 }
00598
00599 n = nodeList.item(0);
00600 e = n.toElement();
00601 n = e.firstChild();
00602 while (!n.isNull())
00603 {
00604 e = n.toElement();
00605 if (!e.isNull())
00606 {
00607 if (e.tagName() == "title")
00608 {
00609 m_title_text->SetText(e.text());
00610 m_progTitle_text->SetText(e.text());
00611 m_subtitle_text->SetText("");
00612 m_starttime_text->SetText("");
00613 m_progDateTime_text->SetText("");
00614 }
00615
00616 if (e.tagName() == "plot")
00617 {
00618 m_progDescription_text->SetText(e.text());
00619 }
00620 }
00621 n = n.nextSibling();
00622 }
00623
00624 m_chanID_text->SetText("N/A");
00625 m_chanNo_text->SetText("N/A");
00626 m_chanName_text->SetText("N/A");
00627 m_callsign_text->SetText("N/A");
00628 m_localChanID_text->SetText("N/A");
00629 m_localChanNo_text->SetText("N/A");
00630 m_localChanName_text->SetText("N/A");
00631 m_localCallsign_text->SetText("N/A");
00632
00633 m_isValidXMLSelected = true;
00634 }
00635 }
00636 else
00637 {
00638 m_title_text->SetText("");
00639 m_subtitle_text->SetText("");
00640 m_starttime_text->SetText("");
00641 cout << "Not a native archive file" << endl;
00642 }
00643 }
00644
00645 void ImportNativeWizard::findChannelMatch(const QString &chanID, const QString &chanNo,
00646 const QString &name, const QString &callsign)
00647 {
00648
00649
00650
00651 MSqlQuery query(MSqlQuery::InitCon());
00652 query.prepare("SELECT chanid, channum, name, callsign FROM channel "
00653 "WHERE chanid = :CHANID AND channum = :CHANNUM AND name = :NAME "
00654 "AND callsign = :CALLSIGN;");
00655 query.bindValue(":CHANID", chanID);
00656 query.bindValue(":CHANNUM", chanNo);
00657 query.bindValue(":NAME", name);
00658 query.bindValue(":CALLSIGN", callsign);
00659
00660 query.exec();
00661 if (query.isActive() && query.numRowsAffected())
00662 {
00663
00664 query.first();
00665 m_localChanID_text->SetText(query.value(0).toString());
00666 m_localChanNo_text->SetText(query.value(1).toString());
00667 m_localChanName_text->SetText(query.value(2).toString());
00668 m_localCallsign_text->SetText(query.value(3).toString());
00669 return;
00670 }
00671
00672
00673 query.prepare("SELECT chanid, channum, name, callsign FROM channel "
00674 "WHERE callsign = :CALLSIGN;");
00675 query.bindValue(":CALLSIGN", callsign);
00676
00677 query.exec();
00678 if (query.isActive() && query.numRowsAffected())
00679 {
00680
00681 query.first();
00682 m_localChanID_text->SetText(query.value(0).toString());
00683 m_localChanNo_text->SetText(query.value(1).toString());
00684 m_localChanName_text->SetText(query.value(2).toString());
00685 m_localCallsign_text->SetText(query.value(3).toString());
00686 return;
00687 }
00688
00689
00690 query.prepare("SELECT chanid, channum, name, callsign FROM channel "
00691 "WHERE name = :NAME;");
00692 query.bindValue(":NAME", callsign);
00693
00694 query.exec();
00695 if (query.isActive() && query.numRowsAffected())
00696 {
00697
00698 query.first();
00699 m_localChanID_text->SetText(query.value(0).toString());
00700 m_localChanNo_text->SetText(query.value(1).toString());
00701 m_localChanName_text->SetText(query.value(2).toString());
00702 m_localCallsign_text->SetText(query.value(3).toString());
00703 return;
00704 }
00705
00706
00707 m_localChanID_text->SetText("");
00708 m_localChanNo_text->SetText("");
00709 m_localChanName_text->SetText("");
00710 m_localCallsign_text->SetText("");
00711 }
00712
00713 bool ImportNativeWizard::showList(const QString &caption, QString &value)
00714 {
00715 bool res = false;
00716
00717 MythSearchDialog *searchDialog = new MythSearchDialog(gContext->GetMainWindow(), "");
00718 searchDialog->setCaption(caption);
00719 searchDialog->setSearchText(value);
00720 searchDialog->setItems(m_searchList);
00721 DialogCode rescode = searchDialog->ExecPopupAtXY(-1, 8);
00722 if (kDialogCodeRejected != rescode)
00723 {
00724 value = searchDialog->getResult();
00725 res = true;
00726 }
00727
00728 searchDialog->deleteLater();
00729 setActiveWindow();
00730
00731 return res;
00732 }
00733
00734 void ImportNativeWizard::fillSearchList(const QString &field)
00735 {
00736 m_searchList.clear();
00737
00738 QString querystr;
00739 querystr = QString("SELECT %1 FROM channel ORDER BY %2").arg(field).arg(field);
00740
00741 MSqlQuery query(MSqlQuery::InitCon());
00742 query.exec(querystr);
00743
00744 if (query.isActive() && query.size())
00745 {
00746 while (query.next())
00747 {
00748 m_searchList << QString::fromUtf8(query.value(0).toString());
00749 }
00750 }
00751 }
00752
00753 void ImportNativeWizard::searchChanID()
00754 {
00755 QString s;
00756
00757 fillSearchList("chanid");
00758
00759 s = m_chanID_text->GetText();
00760 if (showList(tr("Select a ChanID"), s))
00761 {
00762 MSqlQuery query(MSqlQuery::InitCon());
00763 query.prepare("SELECT chanid, channum, name, callsign "
00764 "FROM channel WHERE chanid = :CHANID;");
00765 query.bindValue(":CHANID", s);
00766 query.exec();
00767
00768 if (query.isActive() && query.numRowsAffected())
00769 {
00770 query.next();
00771 m_localChanID_text->SetText(query.value(0).toString());
00772 m_localChanNo_text->SetText(query.value(1).toString());
00773 m_localChanName_text->SetText(query.value(2).toString());
00774 m_localCallsign_text->SetText(query.value(3).toString());
00775 }
00776 }
00777 }
00778
00779 void ImportNativeWizard::searchChanNo()
00780 {
00781 QString s;
00782
00783 fillSearchList("channum");
00784
00785 s = m_chanNo_text->GetText();
00786 if (showList(tr("Select a ChanNo"), s))
00787 {
00788 MSqlQuery query(MSqlQuery::InitCon());
00789 query.prepare("SELECT chanid, channum, name, callsign "
00790 "FROM channel WHERE channum = :CHANNUM;");
00791 query.bindValue(":CHANNUM", s);
00792 query.exec();
00793
00794 if (query.isActive() && query.numRowsAffected())
00795 {
00796 query.next();
00797 m_localChanID_text->SetText(query.value(0).toString());
00798 m_localChanNo_text->SetText(query.value(1).toString());
00799 m_localChanName_text->SetText(query.value(2).toString());
00800 m_localCallsign_text->SetText(query.value(3).toString());
00801 }
00802 }
00803 }
00804
00805 void ImportNativeWizard::searchName()
00806 {
00807 QString s;
00808
00809 fillSearchList("name");
00810
00811 s = m_chanName_text->GetText();
00812 if (showList(tr("Select a Channel Name"), s))
00813 {
00814 MSqlQuery query(MSqlQuery::InitCon());
00815 query.prepare("SELECT chanid, channum, name, callsign "
00816 "FROM channel WHERE name = :NAME;");
00817 query.bindValue(":NAME", s);
00818 query.exec();
00819
00820 if (query.isActive() && query.numRowsAffected())
00821 {
00822 query.next();
00823 m_localChanID_text->SetText(query.value(0).toString());
00824 m_localChanNo_text->SetText(query.value(1).toString());
00825 m_localChanName_text->SetText(query.value(2).toString());
00826 m_localCallsign_text->SetText(query.value(3).toString());
00827 }
00828 }
00829 }
00830
00831 void ImportNativeWizard::searchCallsign()
00832 {
00833 QString s;
00834
00835 fillSearchList("callsign");
00836
00837 s = m_callsign_text->GetText();
00838 if (showList(tr("Select a Callsign"), s))
00839 {
00840 MSqlQuery query(MSqlQuery::InitCon());
00841 query.prepare("SELECT chanid, channum, name, callsign "
00842 "FROM channel WHERE callsign = :CALLSIGN;");
00843 query.bindValue(":CALLSIGN", s);
00844 query.exec();
00845
00846 if (query.isActive() && query.numRowsAffected())
00847 {
00848 query.next();
00849 m_localChanID_text->SetText(query.value(0).toString());
00850 m_localChanNo_text->SetText(query.value(1).toString());
00851 m_localChanName_text->SetText(query.value(2).toString());
00852 m_localCallsign_text->SetText(query.value(3).toString());
00853 }
00854 }
00855 }