void KImportDialog::applyConverter() { kdDebug(5300) << "KImportDialog::applyConverter" << endl; KProgressDialog pDialog(this, 0, i18n("Importing Progress"), i18n("Please wait while the data is imported."), true); pDialog.setAllowCancel(true); pDialog.showCancelButton(true); pDialog.setAutoClose(true); KProgress *progress = pDialog.progressBar(); progress->setTotalSteps(mTable->numRows() - 1); progress->setValue(0); readFile(0); pDialog.show(); for(uint i = mStartRow->value() - 1; i < mData.count() && !pDialog.wasCancelled(); ++i) { mCurrentRow = i; progress->setValue(i); if(i % 5 == 0) // try to avoid constantly processing events kapp->processEvents(); convertRow(); } }
void QSearchDisplayModel::OnTorrentDownloaded(QUrl url, QTemporaryFile* pFile) { boost::scoped_ptr<QTemporaryFile> pSafeFile(pFile); boost::scoped_ptr<OpenTorrentDialog> pDialog(new OpenTorrentDialog()); pDialog->SetData(pSafeFile->fileName()); pDialog->exec(); }
//----------------------------------------------------------------------------- //! Display Todays Activity Dialog //----------------------------------------------------------------------------- void tTripHistoryList::DisplayTodaysActivityDialog() { QScopedPointer<tTodaysActivityDialog> pDialog(m_MfdUiHeroicFactory.CreateTodaysActivityDialog(this)); //Execute the dialog pDialog->exec(); }
void CBaseTopPane::ActionLoad() { // Get the directory std::string sPresetDirectory = mpGUI->GetPresetFolder(); // Get product name tchar pszProductName[128]; GetPlugIn()->GetProductName(pszProductName); // Create the dialog CAutoDelete<ge::IOpenDialog> pDialog(ge::IOpenDialog::Create()); // Open dialog tchar pszPathName[512]; pDialog->DoDialog((tchar*)pszPathName, (tchar*)(sPresetDirectory.c_str()), (tchar*)"*.preset", (tchar*)(std::string(pszProductName) + " Presets (*.preset)").c_str()); if (pszPathName[0] == 0) { // Error in dialog, or user pressed cancel return; } msPresetPathName = std::string((char*)pszPathName); CAutoDelete<IChunkFile> pFile(IChunkFile::Create()); tint32 iVersionNumber; if (pFile->Open((const tchar*)(msPresetPathName.c_str()), IFile::FileRead, iVersionNumber)) { mpGUI->OnLoadPreset(pFile); } }
//----------------------------------------------------------------------------- //! A Trip widget has been triggered [SLOT] //----------------------------------------------------------------------------- void tTripHistoryList::OnTripSelected() { //Find which widget emitted the signal QWidget* pEmittingWidget = qobject_cast<QWidget*>( sender() ); //Handle the failing cast if(pEmittingWidget == 0) { return; } //Find the data for this widget (if it exists) if(m_WidgetToDataMap.contains(pEmittingWidget)) { tTripData tripData = m_WidgetToDataMap.value(pEmittingWidget); //Create the Trip History Dialog QScopedPointer<tTripHistoryDialog> pDialog( m_MfdUiHeroicFactory.CreateTripHistoryDialog(tripData, this) ); Connect( pDialog.data(), SIGNAL(TripUpdated()), this, SLOT(OnRebuildListAndKeepFocus()) ); pDialog->exec(); } }
void KImportDialog::readFile(int rows) { kdDebug(5300) << "KImportDialog::readFile(): " << rows << endl; mData.clear(); int row, column; enum { S_START, S_QUOTED_FIELD, S_MAYBE_END_OF_QUOTED_FIELD, S_END_OF_QUOTED_FIELD, S_MAYBE_NORMAL_FIELD, S_NORMAL_FIELD } state = S_START; QChar m_textquote = '"'; int m_startline = 0; QChar x; QString field = ""; row = column = 0; QTextStream inputStream(mFile, IO_ReadOnly); inputStream.setEncoding(QTextStream::Locale); KProgressDialog pDialog(this, 0, i18n("Loading Progress"), i18n("Please wait while the file is loaded."), true); pDialog.setAllowCancel(true); pDialog.showCancelButton(true); pDialog.setAutoClose(true); KProgress *progress = pDialog.progressBar(); progress->setTotalSteps(mFile.contains(mSeparator, false)); progress->setValue(0); int progressValue = 0; if(progress->totalSteps() > 0) // We have data pDialog.show(); while(!inputStream.atEnd() && !pDialog.wasCancelled()) { inputStream >> x; // read one char // update the dialog if needed if(x == mSeparator) { progress->setValue(progressValue++); if(progressValue % 15 == 0) // try not to constantly repaint kapp->processEvents(); } if(x == '\r') inputStream >> x; // eat '\r', to handle DOS/LOSEDOWS files correctly switch(state) { case S_START : if(x == m_textquote) { field += x; state = S_QUOTED_FIELD; } else if(x == mSeparator) { ++column; } else if(x == '\n') { ++row; column = 0; } else { field += x; state = S_MAYBE_NORMAL_FIELD; } break; case S_QUOTED_FIELD : if(x == m_textquote) { field += x; state = S_MAYBE_END_OF_QUOTED_FIELD; } else if(x == '\n') { setData(row - m_startline, column, field); field = ""; if(x == '\n') { ++row; column = 0; } else { ++column; } state = S_START; } else { field += x; } break; case S_MAYBE_END_OF_QUOTED_FIELD : if(x == m_textquote) { field += x; state = S_QUOTED_FIELD; } else if(x == mSeparator || x == '\n') { setData(row - m_startline, column, field); field = ""; if(x == '\n') { ++row; column = 0; } else { ++column; } state = S_START; } else { state = S_END_OF_QUOTED_FIELD; } break; case S_END_OF_QUOTED_FIELD : if(x == mSeparator || x == '\n') { setData(row - m_startline, column, field); field = ""; if(x == '\n') { ++row; column = 0; } else { ++column; } state = S_START; } else { state = S_END_OF_QUOTED_FIELD; } break; case S_MAYBE_NORMAL_FIELD : if(x == m_textquote) { field = ""; state = S_QUOTED_FIELD; } case S_NORMAL_FIELD : if(x == mSeparator || x == '\n') { setData(row - m_startline, column, field); field = ""; if(x == '\n') { ++row; column = 0; } else { ++column; } state = S_START; } else { field += x; } } if(rows > 0 && row > rows) break; } fillTable(); }