bool CLogoDialog::fill_users(void) { QString s; CSettings settings; QStringList sls; QString CurUserName; //user name CurUserName=qgetenv( "USER" );//current user name (by OS) if(CurUserName==QString::fromUtf8(""))//OS no support qgetenv { QDir dir(QDir::home()); CurUserName=dir.dirName(); } if(settings.load(QString::fromUtf8("USERS"),s)) { if(s.length()>0) sls=s.split(","); } if(sls.count()<=0)//empty? ui->comboBoxUser->addItem(CurUserName);//add user name fom OS else ui->comboBoxUser->addItems(sls);//add lastest users //- sls.clear(); return true; }
bool CInputDialogOrdering::settings(bool bUpdate) { bool b; CSettings settings; QList<QString> lsSType,lsSValue,lsSUpdateType,lsSUpdateValue; lsSType.push_back(QString("DLG_ORDERING_TABLE_COLUMNS_WIDTHS_WARES")); lsSType.push_back(QString("TABLE_SORT_ORDER_DLG_ORDERING")); //- b=settings.load(lsSType,lsSValue);//load all settings if(b) { if(!bUpdate)//set { //table width if(lsSValue.count()>0) settings.set_table_columns_width(ui->tableWidgetWares,lsSValue[0],200); //table sort if(lsSValue.count()>1) settings.set_table_sort(ui->tableWidgetWares,lsSValue[1],1); } if(bUpdate)//write { //table width if(lsSValue.count()>0) { if(settings.get_table_columns_width(ui->tableWidgetWares,lsSValue[0]))//setting change? { lsSUpdateType.push_back(lsSType[0]); lsSUpdateValue.push_back(lsSValue[0]); } } //table sort if(lsSValue.count()>1) { if(settings.get_table_sort(ui->tableWidgetWares,lsSValue[1]))//setting change? { lsSUpdateType.push_back(lsSType[1]); lsSUpdateValue.push_back(lsSValue[1]); } } //write updates if(lsSUpdateType.count()>0 && lsSUpdateType.count()==lsSUpdateValue.count()) b=settings.write(lsSUpdateType,lsSUpdateValue); } } //- lsSValue.clear(); lsSType.clear(); lsSUpdateValue.clear(); lsSUpdateType.clear(); return b; }
bool CInputDialogWaregroup::settings(bool bUpdate) { bool b; CSettings settings; QList<QString> lsSType,lsSValue,lsSUpdateType,lsSUpdateValue; lsSType.push_back(QString("DLG_WAREGROUP_TREE")); //- b=settings.load(lsSType,lsSValue);//load all settings if(b) { if(!bUpdate)//set { //tree width if(lsSValue.count()>0) settings.set_tree_width(ui->treeWidgetParents,lsSValue[0],500); } if(bUpdate)//write { //tree width if(lsSValue.count()>0) { if(settings.get_tree_width(ui->treeWidgetParents,lsSValue[0]))//setting change? { lsSUpdateType.push_back(lsSType[0]); lsSUpdateValue.push_back(lsSValue[0]); } } //write updates if(lsSUpdateType.count()>0 && lsSUpdateType.count()==lsSUpdateValue.count()) b=settings.write(lsSUpdateType,lsSUpdateValue); } } //- lsSValue.clear(); lsSType.clear(); lsSUpdateValue.clear(); lsSUpdateType.clear(); return b; }
bool CLogoDialog::fill_db_path(void) { QString s,sDbPath; CSettings settings; //default database path's if(QFile::exists(QDir::homePath()+QString::fromUtf8("/lava2/")))//aplication(lava2) installed? sDbPath=QDir::homePath()+QString::fromUtf8("/lava2/lava.sqlite"); else sDbPath=QDir::currentPath()+QString::fromUtf8("/lava.sqlite");//not installed //setting if(settings.load(QString::fromUtf8("DB_PATH"),s)) { if(s.length()>0) sDbPath=s;//load last path } //set ui->lineEdit->setText(sDbPath); return true; }
bool CLogoDialog::push_start(void) { if(m_pDb==NULL) {//error no database interface close(); return false; } int i; QFileInfo file_info; QDateTime dtTiLastSession; QDateTime dtTi=QDateTime().currentDateTime(); QString s,sPath,sError; QString curSel=ui->comboBoxUser->currentText(); QStringList sls; CSettings settings; QMessageBox msg(QMessageBox::Critical,"",""); msg.setWindowTitle(tr("Fehler!")); //database path------------------------check & open db sPath=ui->lineEdit->text(); if(!QFile::exists(sPath)) sError=QString::fromUtf8("Die angegebene Datei \"%1\" existiert nicht!").arg(sPath); else { file_info.setFile(sPath); if(!file_info.permission(QFile::WriteUser)) sError=QString::fromUtf8("Sie haben keine Schreibrechte an dem Ort \"%1\"!").arg(sPath); else { if(!m_pDb->open_db(sPath,QString::fromUtf8("localhost")))//open db? { s=m_pDb->last_error(); sError=QString::fromUtf8("Die Datei \"%1\" konnte nicht geöffnet werden!\n(error: %2)").arg(sPath,s); } else { if(!m_pDb->check_and_update_db_version())//database old version? -> update sError=QString::fromUtf8("Fehler beim update der Datenbankdatei auf Version %1!").arg(CURRENT_DB_VERSION); else { if(!m_pDb->check_database_file(true)) sError=QString::fromUtf8("Die Datei \"%1\" ist beschädigt oder nicht kompatibel!").arg(sPath); else { //save path->settings settings.write(QString::fromUtf8("DB_PATH"),sPath);//save setting //mark path m_sDbPath=sPath; //check last session(time) and current dtTiLastSession=m_pDb->get_last_session(); if(dtTiLastSession>QDateTime(QDate(0,0,0),QTime(0,0,0)))//set? { if(dtTiLastSession.date()>dtTi.date()) { s=QString::fromUtf8("Bitte prüfen Sie Ihre Systemzeit-/datumseinstellungen Ihres Betriebssystems. Das Datum Ihrer letzten Sitzung " "ist später als das aktuelle Datum. Falsche Einstellungen können die chronologische Reihenfolge der Artikelmengen" " beim Warenausgang beeinflussen."); msg.setWindowTitle(QString::fromUtf8("Achtung!")); msg.setText(s); msg.exec(); } } } } } } } //------------------------------------- if(sError.length()>0) { msg.setText(sError); msg.exec(); m_pDb->close_db(); } else { //user name----------------------------- //mark user name if(settings.load(QString::fromUtf8("USERS"),s)) { if(s.length()>0) sls=s.split(","); } //add current selection text in front sls.push_front(curSel); //remove dupl. sls.removeDuplicates(); //max mark user = 10 while(sls.count()>10) sls.removeLast(); //save user setting for(i=0,s=QString::fromUtf8("");i<sls.count();i++) { if(sls[i]!=QString::fromUtf8("")) { s+=sls[i]; if(i+1<sls.count())//not last s+=QString::fromUtf8(","); } } settings.write(QString::fromUtf8("USERS"),s);//save setting sls.clear(); //------------------------------------------- m_sUser=curSel; m_bStart=true; close(); } return true; }