void LuaAVConsole :: removeScript(const char *name, const char *filename) { QList<QString> data = mScriptModel->getList(); QString qfilename(filename); int i=0; for(QList<QString>::iterator it = data.begin(); it != data.end(); ++it) { if((*it).compare(qfilename) == 0) { mScriptModel->removeRows(i, 1, QModelIndex()); if(i == mSelectedScript) { mSelectedScript = data.size()-1; } int j=0; for(std::vector<ScriptData *>::iterator sit = mScripts.begin(); sit != mScripts.end(); ++sit) { if(i == j) { ScriptData *sd = *sit; mScripts.erase(sit); delete sd; break; } j++; } } i++; } }
bool Csv_infilter::can_handle( const std::string& filename ){ // To figure out if a file is a csv formatted file we do: // - read the first line, and store the nuber of comma delimieted entries // - Read the next 10 lines to ensure that the same number of entries than the first line QString qfilename(filename.c_str()); if( !qfilename.endsWith(".csv",Qt::CaseInsensitive) )return false; QFile file( filename.c_str() ); if( !file.open( QIODevice::ReadOnly ) ) return false; QTextStream stream( &file ); stream.readLine(); if( stream.atEnd() ) return false; QString str; stream >> str; stream.readLine(); int nProperties = str.split(",").size(); // int nPropertiesSpace = str.split(" ").size(); bool ok; int test = str.toInt(&ok); if( ok ) return false; for( int i= 0; i < 10; i++ ) { if(stream.atEnd()) return true; stream.readLine(); if( nProperties != str.split(",").size() ) return false; } return true; }