28 QString errorLocal=
"Error";
32 void setErrorLocal(QString s)
42 int getIndexOf(QStringList l,QString s)
45 for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it )
57 QStringList::Iterator i = source->begin();
58 while(i != source->end())
59 target->push_back(*i);
63 QString convNationalToHtmlCodes(QString input)
87 r.replace(
"á",
"á",Qt::CaseSensitive);
88 r.replace(
"é",
"é",Qt::CaseSensitive);
89 r.replace(
"í",
"í",Qt::CaseSensitive);
90 r.replace(
"ó",
"ó",Qt::CaseSensitive);
91 r.replace(
"ö",
"ö",Qt::CaseSensitive);
92 r.replace(
"õ",
"ő",Qt::CaseSensitive);
93 r.replace(
"ú",
"ú",Qt::CaseSensitive);
94 r.replace(
"ü",
"ü",Qt::CaseSensitive);
95 r.replace(
"û",
"ű",Qt::CaseSensitive);
97 r.replace(
"Á",
"Á",Qt::CaseSensitive);
98 r.replace(
"É",
"É",Qt::CaseSensitive);
99 r.replace(
"Í",
"Í",Qt::CaseSensitive);
100 r.replace(
"Ó",
"Ó",Qt::CaseSensitive);
101 r.replace(
"Ö",
"Ö",Qt::CaseSensitive);
102 r.replace(
"Õ",
"Ő",Qt::CaseSensitive);
103 r.replace(
"Ú",
"Ú",Qt::CaseSensitive);
104 r.replace(
"Ü",
"Ü",Qt::CaseSensitive);
105 r.replace(
"Û",
"Ű",Qt::CaseSensitive);
109 int my_dtoa(
double v,
char *buffer,
int bufflen,
int min,
int max,
int group)
118 unsigned long int i_ip,i_fp,idigit_value;
139 fp = fabs(modf(v,&ip));
144 fp = floor(fp + 0.5);
162 while(idigit_value*10 <= i_ip)
168 while(idigit_value >= 1)
171 if(group && forlength != 0 && digitnum % 3 == 0)
175 if(length >= bufflen)
182 digit =
static_cast<char>((i_ip - i_ip%idigit_value) / idigit_value);
183 i_ip = i_ip%idigit_value;
185 *(str++) =
'0' + digit%10;
191 if(length >= bufflen)
209 while (idigit_value >= 1)
211 if(group && digitnum && digitnum%3 == 0)
215 if(length >= bufflen)
222 digit =
static_cast<char>((i_fp - i_fp%idigit_value) / idigit_value);
223 i_fp = i_fp%idigit_value;
225 *(str++) =
'0' + digit%10;
230 if(length >= bufflen)
236 if(digitnum >= min && i_fp == 0)
246 for(digitnum=0;digitnum<min;)
248 if(group && digitnum && digitnum%3 == 0)
252 if(length >= bufflen)
261 if(length >= bufflen)
281 my_dtoa(val,buffer,128,min,max,group);
288 double intpart = floor(val);
289 if(mode == ROUND_FLOOR)
291 if( (val-intpart) >= 0.5 )
292 return (intpart + 1.0);
302 output_stream = NULL;
303 node_stack =
new QStack<QString>();
311 output_stream = NULL;
317 return output_stream;
327 QString visible_enc=enc;
331 if(enc ==
"CP1250") visible_enc=
"Windows-1250";
332 if(enc ==
"UTF-8") visible_enc=
"UTF-8";
336 (*output_stream) <<
"<?xml version=\"1.0\" encoding=\"" + visible_enc +
"\"?>\r\n";
339 tc = QTextCodec::codecForName(codec_name.toLocal8Bit().constData());
345 void HXmlWriter::eatData(QString d)
348 (*output_stream) << d;
355 if(!parameters.isEmpty())
356 parameters.prepend(
" ");
357 eatData( QString().fill(
'\t',indent_pos++) +
"<" + n + parameters +
">\r\n" );
363 eatData( QString().fill(
'\t',--indent_pos) +
"</" + node_stack->pop() +
">\r\n" );
368 if(!parameters.isEmpty())
369 parameters.prepend(
" ");
371 eatData( QString().fill(
'\t',indent_pos) +
"<" + n + parameters +
">" + data +
"</" + n +
">\r\n");
376 if(!parameters.isEmpty())
377 parameters.prepend(
" ");
379 eatData( QString().fill(
'\t',indent_pos) +
"<" + n + parameters +
"/>\r\n" );
397 rv = d.toLocal8Bit();
399 rv = tc->fromUnicode(d);
410 error(
"Critical Error: The \"HRefreshAgent\" object must be only one instance!");
413 sdebug(
"HRefreshAgent initialized...");
417 HRefreshAgent::~HRefreshAgent(
void)
426 error(
"Critical Error: The \"HRefreshAgent\" class is uninitialized!");
430 theone->internalNotify(tblname);
433 int HRefreshAgent::notifySlot(QString tblname)
435 theone->internalNotify(tblname);
439 void HRefreshAgent::internalNotify(QString tblname)
441 sdebug(
"*** HRefreshAgent::internalNotify ***");
449 #ifdef MODULE_REFRESHAGENT_NETSERVER
451 bool HRefreshAgentNetserver::inNotify =
false;
459 error(
"Critical Error: The \"HRefreshAgentNetserver\" object must be only one instance!");
462 sdebug(
"[HRefreshAgentNetserver] Initializing...");
466 tcpServer =
new QTcpServer(
this);
467 if (!tcpServer->listen(QHostAddress::Any,REFRESHAGENT_TCPPORT))
469 error(QString(
"Unable to start tcpserver: %1.")
470 .arg(tcpServer->errorString()));
473 connect(tcpServer,SIGNAL(newConnection()),
this,SLOT(newConn()));
474 sdebug(QString(
"[HRefreshAgentNetserver] Listening on port %1...").arg(tcpServer->serverPort()));
480 if(theone->tcpServer == NULL || !theone->tcpServer->isListening())
487 if(theone->tcpServer != NULL && theone->tcpServer->isListening())
489 return theone->laddr;
491 return QString(
"Not listening");
494 int HRefreshAgentNetserver::newConn(
void)
496 sdebug(
"*** HRefreshAgentNetserver::newConn ***");
500 QTextStream inout(&block,QIODevice::ReadWrite);
502 if(!tcpServer->hasPendingConnections())
504 sdebug(
"*** HRefreshAgentNetserver::newConn *** END ERROR");
508 socket = tcpServer->nextPendingConnection();
510 laddr = socket->localAddress().toString();
512 inout <<
"ConnectOk" <<endl;
513 socket->write(block);
514 connect(socket,SIGNAL(readyRead()),
this,SLOT(request()));
515 connect(socket,SIGNAL(disconnected()),
this,SLOT(clientLeaving()));
517 tcps_list.push_back(socket);
519 sdebug(QString(
"[HRefreshAgentNetserver] Client connected %1... (have %2 client)")
520 .arg(socket->peerAddress().toString())
521 .arg(tcps_list.size()));
523 sdebug(
"*** HRefreshAgentNetserver::newConn *** END");
527 int HRefreshAgentNetserver::request(
void)
531 sdebug(
"*** HRefreshAgentNetserver::request ***");
535 QTextStream inout(&block,QIODevice::ReadWrite);
537 QList<QTcpSocket *>::iterator is;
540 is = tcps_list.begin();
543 while(is != tcps_list.end())
546 if(socket != NULL && socket->isValid())
547 if(socket->state() == QAbstractSocket::ConnectedState)
548 if(socket->bytesAvailable() != 0)
550 block = socket->readAll();
552 sdebug(QString(
"[HRefreshAgentNetserver] Data arrived: \"%1\" from %2 !")
554 .arg(socket->peerAddress().toString()));
556 if(!str.isEmpty() && (str ==
"close" ||
559 str ==
"disconnect"))
562 socket->disconnectFromHost();
571 if(!str.isEmpty() && str.startsWith(
"<") && str.endsWith(
">") )
573 int length = str.length();
574 str = str.mid(1,length-2);
578 sdebug(
"*** HRefreshAgentNetserver::request *** END");
582 int HRefreshAgentNetserver::action(QString name,
int sendernum)
586 QTextStream inout(&block,QIODevice::ReadWrite);
592 sdebug(
"[HRefreshAgentNetserver] NetServer Notify: "+name);
594 inout <<
"<" << name <<
">" << endl;
596 QList<QTcpSocket *>::iterator is;
597 is = tcps_list.begin();
598 while(is != tcps_list.end())
600 if((*is)->state() == QAbstractSocket::ConnectedState)
610 int HRefreshAgentNetserver::clientLeaving(
void)
612 QList<QTcpSocket *>::iterator is;
613 is = tcps_list.begin();
614 while(is != tcps_list.end())
616 if((*is)->state() == QAbstractSocket::UnconnectedState ||
617 (*is)->state() == QAbstractSocket::ClosingState )
619 tcps_list.removeAll(*is);
620 sdebug(QString(
"[HRefreshAgentNetserver] Client leaving... (have %1 client)").arg(tcps_list.size()));
630 QList<QTcpSocket *>::iterator is;
632 is = tcps_list.begin();
633 while(is != tcps_list.end())
651 #ifdef MODULE_REFRESHAGENT_NETCLIENT
653 bool HRefreshAgentNetclient::inNotify =
false;
660 error(
"Critical Error: The \"HRefreshAgentNetclient\" object must be only one instance!");
663 sdebug(
"HRefreshAgentNetclient initialized...");
667 socket =
new QTcpSocket(
this);
668 socket->connectToHost(server_ip,REFRESHAGENT_TCPPORT,QIODevice::ReadWrite);
670 connect(socket,SIGNAL(readyRead()),
this,SLOT(request()));
671 connect(socket,SIGNAL(disconnected()),
this,SLOT(serverClosing()));
678 if(theone->socket->state() == QAbstractSocket::ConnectedState && theone->c_ok)
691 int HRefreshAgentNetclient::request(
void)
696 QTextStream inout(&block,QIODevice::ReadWrite);
699 if(socket->state() == QAbstractSocket::ConnectedState && socket->bytesAvailable() != 0)
701 block = socket->readAll();
703 sdebug(QString(
"[HRefreshAgentNetclient] Data arrived: \"%1\" ").arg(str));
704 if(!c_ok && str ==
"ConnectOk")
706 sdebug(QString(
"[HRefreshAgentNetclient] Connection established."));
713 if(c_ok && !str.isEmpty() && str.startsWith(
"<") && str.endsWith(
">"))
715 int length = str.length();
716 str = str.mid(1,length-2);
717 sdebug(QString(
"[HRefreshAgentNetclient] HRefreshAgent->notify: \"%1\"").arg(str));
725 int HRefreshAgentNetclient::serverClosing(
void)
730 sdebug(
"[HRefreshAgentNetclient] The server closed the connection.");
734 int HRefreshAgentNetclient::action(QString name)
737 QTextStream inout(&block,QIODevice::ReadWrite);
746 sdebug(
"[HRefreshAgentNetserver] Send Notify: "+name);
748 inout <<
"<" << name <<
">" << endl;
749 QList<QTcpSocket *>::iterator is;
751 if(socket->state() == QAbstractSocket::ConnectedState)
752 socket->write(block);
783 HSqlSingleInterface::HSqlSingleInterface(
void)
788 HSqlSingleInterface_SqliteWin::HSqlSingleInterface_SqliteWin(
void)
816 HSqlSingleInterface_SqliteLin::HSqlSingleInterface_SqliteLin(
void)
819 hsqli_currentModeName =
"QtSqlite_Lin";
820 hsqli_usequerysize =
false;
821 hsqli_booleantypename =
"BOOLEAN";
822 hsqli_truevalue =
"1";
823 hsqli_falsevalue =
"0";
824 hsqli_hkeytype_varchar_int =
false;
825 hsqli_varcharhkeylength = 15;
826 hsqli_hkeyconstraint =
"PRIMARY KEY AUTOINCREMENT";
827 hsqli_need_create_sequence_before=
false;
828 hsqli_sequence_creation_string=
"";
829 hsqli_charhash_varcharlength = 5;
830 hsqli_smalltext_varcharlength = 256;
831 hsqli_largetext_sizemustdefine =
false;
832 hsqli_largetext_varcharlength = 2048;
833 hsqli_numbertypename =
"INTEGER";
834 hsqli_floattypename =
"REAL";
835 hsqli_hastimestamptype =
false;
836 hsqli_hasdatetype =
false;
837 hsqli_timestamptypename =
"VARCHAR";
838 hsqli_datetypename =
"VARCHAR";
839 hsqli_timestampnowvalue =
"datetime(current_timestamp,\'localtime\')";
840 hsqli_sqlchooseconstraint =
false;
841 hsqli_appendsqlerrormsg =
false;
842 hsqli_hackconvert_stdsqlconcatenation_to_local = 0;
845 HSqlSingleInterface_PsqlOdbcWin::HSqlSingleInterface_PsqlOdbcWin(
void)
848 hsqli_currentModeName =
"PostgreSQL_WinOdbc";
849 hsqli_usequerysize =
true;
850 hsqli_booleantypename =
"BOOLEAN";
851 hsqli_truevalue =
"TRUE";
852 hsqli_falsevalue =
"FALSE";
853 hsqli_hkeytype_varchar_int =
true;
854 hsqli_varcharhkeylength = 15;
855 hsqli_hkeyconstraint =
"PRIMARY KEY DEFAULT(nextval(\'_SEQNAME_\'))";
856 hsqli_need_create_sequence_before=
true;
857 hsqli_sequence_creation_string=
"CREATE SEQUENCE _SEQNAME_ INCREMENT 1 START 1";
858 hsqli_charhash_varcharlength = 5;
859 hsqli_smalltext_varcharlength = 512;
860 hsqli_largetext_sizemustdefine =
false;
861 hsqli_largetext_varcharlength = 4096;
862 hsqli_numbertypename =
"NUMERIC";
863 hsqli_floattypename =
"NUMERIC";
864 hsqli_hastimestamptype =
true;
865 hsqli_hasdatetype =
true;
866 hsqli_timestamptypename =
"TIMESTAMP";
867 hsqli_datetypename =
"DATE";
868 hsqli_timestampnowvalue =
"now()";
869 hsqli_sqlchooseconstraint =
true;
870 hsqli_appendsqlerrormsg =
false;
871 hsqli_hackconvert_stdsqlconcatenation_to_local = 0;
874 HSqlSingleInterface_PostgresqlLin::HSqlSingleInterface_PostgresqlLin(
void)
877 hsqli_currentModeName =
"PostgreSQL_LinPsql";
878 hsqli_usequerysize =
false;
879 hsqli_booleantypename =
"BOOLEAN";
880 hsqli_truevalue =
"TRUE";
881 hsqli_falsevalue =
"FALSE";
882 hsqli_hkeytype_varchar_int =
true;
883 hsqli_varcharhkeylength = 15;
884 hsqli_hkeyconstraint =
"PRIMARY KEY DEFAULT(nextval(\'_SEQNAME_\'))";
885 hsqli_need_create_sequence_before=
true;
886 hsqli_sequence_creation_string=
"CREATE SEQUENCE _SEQNAME_ INCREMENT 1 START 1";
887 hsqli_charhash_varcharlength = 5;
888 hsqli_smalltext_varcharlength = 512;
889 hsqli_largetext_sizemustdefine =
false;
890 hsqli_largetext_varcharlength = 4096;
891 hsqli_numbertypename =
"NUMERIC";
892 hsqli_floattypename =
"NUMERIC";
893 hsqli_hastimestamptype =
true;
894 hsqli_hasdatetype =
true;
895 hsqli_timestamptypename =
"TIMESTAMP";
896 hsqli_datetypename =
"DATE";
897 hsqli_timestampnowvalue =
"now()";
898 hsqli_sqlchooseconstraint =
true;
899 hsqli_appendsqlerrormsg =
false;
900 hsqli_hackconvert_stdsqlconcatenation_to_local = 0;
903 HSqlSingleInterface_MysqlOdbcWin::HSqlSingleInterface_MysqlOdbcWin(
void)
906 hsqli_currentModeName =
"MYSQL_WinOdbc";
907 hsqli_usequerysize =
true;
908 hsqli_booleantypename =
"TINYINT(1)";
909 hsqli_truevalue =
"1";
910 hsqli_falsevalue =
"0";
911 hsqli_hkeytype_varchar_int =
false;
912 hsqli_varcharhkeylength = 15;
913 hsqli_hkeyconstraint =
"PRIMARY KEY NOT NULL AUTO_INCREMENT";
914 hsqli_need_create_sequence_before=
false;
915 hsqli_sequence_creation_string=
"";
916 hsqli_charhash_varcharlength = 5;
917 hsqli_smalltext_varcharlength = 512;
918 hsqli_largetext_sizemustdefine =
true;
919 hsqli_largetext_varcharlength = 4096;
920 hsqli_numbertypename =
"INTEGER";
921 hsqli_floattypename =
"DOUBLE";
922 hsqli_hastimestamptype =
true;
923 hsqli_hasdatetype =
true;
924 hsqli_timestamptypename =
"TIMESTAMP";
925 hsqli_datetypename =
"DATE";
926 hsqli_timestampnowvalue =
"now()";
927 hsqli_sqlchooseconstraint =
true;
928 hsqli_appendsqlerrormsg =
true;
929 hsqli_hackconvert_stdsqlconcatenation_to_local = 1;
932 HSqlSingleInterface_MysqlLin::HSqlSingleInterface_MysqlLin(
void)
935 hsqli_currentModeName =
"MYSQL_LinQt";
936 hsqli_usequerysize =
false;
937 hsqli_booleantypename =
"TINYINT(1)";
938 hsqli_truevalue =
"1";
939 hsqli_falsevalue =
"0";
940 hsqli_hkeytype_varchar_int =
false;
941 hsqli_varcharhkeylength = 15;
942 hsqli_hkeyconstraint =
"PRIMARY KEY NOT NULL AUTO_INCREMENT";
943 hsqli_need_create_sequence_before=
false;
944 hsqli_sequence_creation_string=
"";
945 hsqli_charhash_varcharlength = 5;
946 hsqli_smalltext_varcharlength = 512;
947 hsqli_largetext_sizemustdefine =
true;
948 hsqli_largetext_varcharlength = 4096;
949 hsqli_numbertypename =
"INTEGER";
950 hsqli_floattypename =
"DOUBLE";
951 hsqli_hastimestamptype =
true;
952 hsqli_hasdatetype =
true;
953 hsqli_timestamptypename =
"TIMESTAMP";
954 hsqli_datetypename =
"DATE";
955 hsqli_timestampnowvalue =
"now()";
956 hsqli_sqlchooseconstraint =
true;
957 hsqli_appendsqlerrormsg =
true;
958 hsqli_hackconvert_stdsqlconcatenation_to_local = 1;
992 bool HSqlInterface::isset =
false;
993 int HSqlInterface::currentDefaultInterface = 0;
994 int HSqlInterface::defaultDefaultInterface = -1;
1002 error(
"HSqlInterface: Define a sql interface model with HSqlInterface::setSqlMode() !");
1003 QCoreApplication::quit();
1006 myinterface = currentDefaultInterface;
1018 for(i=0;i<MAX_SQL_INTERFACES;++i)
1019 interfaces[i] = NULL;
1030 for(i=0;i<MAX_SQL_INTERFACES;++i)
1031 if(interfaces[i] != NULL && interfaces[i]->hsqli_currentModeName == modename)
1034 if(newdefmode == -1)
1036 error(
"HSqlInterface::setSqlMode : Unknown sql mode!");
1037 QCoreApplication::quit();
1041 if(defaultDefaultInterface == -1)
1042 defaultDefaultInterface = newdefmode;
1044 currentDefaultInterface = newdefmode;
1049 if(defaultDefaultInterface != -1)
1050 currentDefaultInterface = defaultDefaultInterface;
1055 return interfaces[currentDefaultInterface];
1062 for(i=0;i<MAX_SQL_INTERFACES;++i)
1063 if(interfaces[i] != NULL && interfaces[i]->hsqli_currentModeName == interfacename)
1064 return interfaces[i];
1070 if(interfaces[myinterface]->hsqli_hackconvert_stdsqlconcatenation_to_local == 0)
1073 if(interfaces[myinterface]->hsqli_hackconvert_stdsqlconcatenation_to_local == 1)
1075 QString newconc,inner;
1077 inner.replace(
"||",
",");
1078 newconc =
"CONCAT("+inner+
")";
1081 if(interfaces[myinterface]->hsqli_hackconvert_stdsqlconcatenation_to_local == 2)
1085 newconc.replace(
"||",
"+");
1088 return "Error, uncnown string concatenation method!";
1095 QStringList::iterator i;
1097 switch(interfaces[myinterface]->hsqli_hackconvert_stdsqlconcatenation_to_local)
1099 case 0: sep =
"||";
break;
1100 case 1: sep =
",";
break;
1101 case 2: sep =
"+";
break;
1105 for(i=fields.begin();i!=fields.end();++i)
1107 result += (fieldnum == 0 ?
"" : sep) + *i;
1111 if(interfaces[myinterface]->hsqli_hackconvert_stdsqlconcatenation_to_local == 1)
1112 result =
"CONCAT("+result+
")";
1121 bool HSqlHandler::globalnew_nodefault =
false;
1122 QString HSqlHandler::globalnew_current_database =
"";
1126 globalnew_nodefault =
true;
1127 globalnew_current_database = databaseName;
1128 if(!sqlinterfacename.isEmpty())
1134 globalnew_nodefault =
false;
1135 globalnew_current_database =
"";
1143 query_error_occured =
false;
1144 nodefault = globalnew_nodefault;
1145 current_database = globalnew_current_database;
1152 emit
errorSignal(
"Error: I have some uncommitted/rollback-ed transaction!");
1160 nodefault = other->nodefault;
1161 current_database = other->current_database;
1167 return QSqlDatabase::database();
1169 QSqlDatabase db = QSqlDatabase::database(current_database);
1170 if(!db.isValid() || !db.isOpen())
1172 query_error_occured =
true;
1173 sdebug(QString(
"Cannot load the given database by name \"%1\"!").arg(current_database));
1174 emit
errorSignal(QString(
"Cannot load the given database by name \"%1\"!").arg(current_database));
1175 return QSqlDatabase::database();
1182 return new QSqlQuery(
workDB());
1187 sdebug(QString(
"Begin transaction: %1").arg(
trans));
1189 QSqlDatabase db =
workDB();
1190 if(db.transaction())
return;
1192 emit
errorSignal(
"Cannot begin the SQL transaction!");
1199 emit
errorSignal(
"BIG Warning: Called commit without begin a transaction!");
1201 sdebug(QString(
"Commit transaction: %1").arg(
trans));
1203 QSqlDatabase db =
workDB();
1204 if(db.commit())
return;
1206 emit
errorSignal(
"Cannot COMMIT the SQL transaction!");
1214 emit
errorSignal(
"BIG Warning: Called rollback without begin a transaction!");
1216 sdebug(QString(
"Rollback transaction: %1").arg(
trans));
1218 QSqlDatabase db =
workDB();
1219 if(db.rollback())
return;
1221 emit
errorSignal(
"Cannot ROLLBACK the SQL transaction!");
1227 query_error_occured =
false;
1238 if(qi->lastError().type() != QSqlError::NoError)
1243 QString errortext_new = err;
1246 errortext_new +=
" (" + qi->lastError().text() +
") Sql was:"+q;
1250 query_error_occured =
true;
1264 query_error_occured =
false;
1275 if( (
myInterface()->hsqli_usequerysize && qi->numRowsAffected() != 1) ||
1277 qi->lastError().type() != QSqlError::NoError )
1282 QString errortext_new = err;
1285 errortext_new +=
" (" + qi->lastError().text() +
")";
1289 query_error_occured =
true;
1305 QList<QVariant> list;
1310 query_error_occured =
false;
1319 if((
myInterface()->hsqli_usequerysize && qi->numRowsAffected() < 0) ||
1320 qi->lastError().type() != QSqlError::NoError )
1326 QString errortext_new = err;
1329 errortext_new +=
" (" + qi->lastError().text() +
")";
1333 query_error_occured =
true;
1341 for(i=0 ; i < qi->record().count() ; ++i)
1342 list.push_back( qi->value(i) );
1359 whoami =
"HPlainDataMatrix";
1365 hheader =
new QString[col_count];
1367 printCellWrap =
new bool[col_count];
1368 for(i = 0 ; i < col_count ; ++i)
1369 printCellWrap[i] =
false;
1371 printMaxCellWidth =
new int[col_count];
1372 for(i = 0 ; i < col_count ; ++i)
1373 printMaxCellWidth[i] = 0;
1382 while( !data.isEmpty())
1384 delete[] data.first();
1394 while( !data.isEmpty())
1396 delete[] data.first();
1404 iter = data.begin() ;
1405 iter_ctrl = control.begin();
1408 for(i = 0 ; i < col_count ; ++i)
1409 printCellWrap[i] =
false;
1410 for(i = 0 ; i < col_count ; ++i)
1411 printMaxCellWidth[i] = 0;
1424 for(i = 0 ; i < col_count ; ++i)
1438 return data.count();
1445 hheader[col] = strdata;
1451 for(i = 0; i < col_count;++i)
1453 if(i < strlistdata.count())
1454 hheader[i] = strlistdata.at(i);
1461 ,QString d4,QString d5,QString d6
1462 ,QString d7,QString d8,QString d9
1463 ,QString d10,QString d11,QString d12
1464 ,QString d13,QString d14,QString d15)
1468 for(i = 0; i < col_count;++i)
1472 case 0: s = d1;
break;
1473 case 1: s = d2;
break;
1474 case 2: s = d3;
break;
1475 case 3: s = d4;
break;
1476 case 4: s = d5;
break;
1477 case 5: s = d6;
break;
1478 case 6: s = d7;
break;
1479 case 7: s = d8;
break;
1480 case 8: s = d9;
break;
1481 case 9: s = d10;
break;
1482 case 10: s = d11;
break;
1483 case 11: s = d12;
break;
1484 case 12: s = d13;
break;
1485 case 13: s = d14;
break;
1486 case 14: s = d15;
break;
1487 default: s =
"NOTSUPPORTED";
break;
1497 return hheader[col];
1503 QList<QString> list;
1505 for(i = 0; i < col_count;++i)
1507 list.push_back(hheader[i]);
1517 row =
new QVariant[col_count];
1518 for(i = 0; i < col_count;++i)
1520 if(i < listdata.count())
1521 row[i] = listdata.at(i);
1523 row[i] = QVariant(
"");
1525 data.push_back(row);
1526 control.push_back(ctrl);
1548 row =
new QVariant[col_count];
1549 for(i = 0; i < col_count;++i)
1551 if(i < strlistdata.count())
1552 row[i] = QVariant(strlistdata.at(i));
1554 row[i] = QVariant(
"");
1556 data.push_back(row);
1557 control.push_back(ctrl);
1561 ,QString d4,QString d5,QString d6
1562 ,QString d7,QString d8,QString d9
1563 ,QString d10,QString d11,QString d12
1564 ,QString d13,QString d14,QString d15)
1570 row =
new QVariant[col_count];
1571 for(i = 0; i < col_count;++i)
1575 case 0: s = d1;
break;
1576 case 1: s = d2;
break;
1577 case 2: s = d3;
break;
1578 case 3: s = d4;
break;
1579 case 4: s = d5;
break;
1580 case 5: s = d6;
break;
1581 case 6: s = d7;
break;
1582 case 7: s = d8;
break;
1583 case 8: s = d9;
break;
1584 case 9: s = d10;
break;
1585 case 10: s = d11;
break;
1586 case 11: s = d12;
break;
1587 case 12: s = d13;
break;
1588 case 13: s = d14;
break;
1589 case 14: s = d15;
break;
1590 default: s =
"NOTSUPPORTED";
break;
1592 row[i] = QVariant(s);
1594 data.push_back(row);
1595 control.push_back(ctrl);
1600 if(row < 0 || col < 0)
1601 return QVariant(
"ERROR");
1602 if(row > data.count() || col > col_count)
1603 return QVariant(
"ERROR");
1605 return (data.at(row))[col];
1611 if(row < 0 || col < 0)
1613 if(row > data.count() || col > col_count)
1616 return (data.at(row))[col].toString();
1625 if(data.count() <= 0)
1632 r.append(separator);
1644 if(row < 0 || col < 0)
1646 if(row > data.count() || col > col_count)
1649 (data.at(row))[col] = vdata;
1656 if(row > data.count())
1659 control[row] = ctrl;
1664 if(row < 0 || col < 0)
1666 if(row > data.count() || col > col_count)
1669 (data.at(row))[col] = QVariant(strdata);
1675 QList<QVariant> list;
1677 QVariant *rowdata=NULL;
1678 rowdata = data.at(row);
1680 for(i = 0; i < col_count;++i)
1682 list.push_back(rowdata[i]);
1690 QList<QString> list;
1692 QVariant *rowdata=NULL;
1693 rowdata = data.at(row);
1695 for(i = 0; i < col_count;++i)
1697 list.push_back(rowdata[i].toString());
1706 QVariant *rowdata=NULL;
1707 rowdata = data.at(row);
1709 for(i = 0; i < col_count;++i)
1711 list.append(rowdata[i].toString() + separator);
1718 iter = data.begin();
1719 iter_ctrl = control.begin();
1724 if(iter == data.end())
1730 if(iter == data.end())
1738 if(iter == data.end() || iter_ctrl == control.end())
1745 if(iter == data.end() || iter_ctrl == control.end())
1748 QVariant *to_delete = *iter;
1749 iter = data.erase(iter);
1750 iter_ctrl = control.erase(iter_ctrl);
1751 delete [] to_delete;
1758 QList<QVariant> list;
1760 QVariant *rowdata=NULL;
1763 for(i = 0; i < col_count;++i)
1765 list.push_back(rowdata[i]);
1778 QList<QString> list;
1780 QVariant *rowdata=NULL;
1783 for(i = 0; i < col_count;++i)
1785 list.push_back(rowdata[i].toString());
1794 QVariant *rowdata=NULL;
1797 for(i = 0; i < col_count;++i)
1799 list.append(rowdata[i].toString() + separator);
1806 QList<QVariant *>::iterator iter;
1809 iter = data.begin();
1810 while(iter != data.end())
1816 if(in[col].toString().contains(find))
1820 str = in[col].toString();
1821 str.replace(find,replace);
1822 in[col].setValue(str);
1827 if(in[col].toString() == find)
1828 in[col].setValue(replace);
1837 QList<QVariant *>::iterator iter;
1840 laststr =
"__NOTHING_WAS_BEFORE__";
1841 iter = data.begin();
1842 while(iter != data.end())
1845 if(in[col].toString() == laststr)
1846 in[col].setValue(QString(
""));
1848 laststr = in[col].toString();
1856 QList<QVariant *>::iterator iter;
1859 iter = data.begin();
1860 while(iter != data.end())
1863 str = in[col].toString();
1864 str.prepend(prepend);
1866 in[col].setValue(str);
1875 QList<QVariant *>::iterator iter;
1878 iter = data.begin();
1880 while(iter != data.end())
1883 sum += in[col].toInt();
1893 QList<QVariant *>::iterator iter;
1896 iter = data.begin();
1898 while(iter != data.end())
1901 sum += in[col].toDouble();
1910 QList<QVariant *>::iterator iter;
1913 iter = data.begin();
1915 while(iter != data.end())
1920 sum += in[col].toString();
1930 QList<QVariant *>::iterator iter;
1931 QList<QString>::iterator ctrl_iter;
1936 iter = data.begin();
1937 ctrl_iter = control.begin();
1938 while(iter != data.end())
1940 if(ctrl_iter == control.end())
1941 error(
"HPlainDataMatrix::removeHTMLTags: Control and data count mismatch!");
1944 if(force_all || (*ctrl_iter).contains(
"optionalhtmltags") )
1946 for(i=0;i<col_count;++i)
1948 str = in[i].toString();
1950 str2 = str.replace(QRegExp(
"<[^<>]*>"),
"");
1951 sdebug(
"str:"+str+
","+str2);
1952 in[i].setValue(str2);
1962 int all_width=0,border=0,pad=4,space=1;
1965 QTextStream textstream(&out);
1973 if(params.contains(
"html"))
1975 if(params.contains(
"css") && !htmlcss.isEmpty())
1978 xmlw.
putCData(
"style",htmlcss,
"type=\"text/css\"");
1982 if(params.contains(
"center"))
1984 if(!params.contains(
"notitle"))
1987 QRegExp reg1(
"width=(\\d+)");
1988 if(params.contains(reg1))
1989 all_width = (reg1.capturedTexts()[1]).toInt();
1990 QRegExp reg2(
"border=(\\d+)");
1991 if(params.contains(reg2))
1992 border = (reg2.capturedTexts()[1]).toInt();
1993 QRegExp reg3(
"pad=(\\d+)");
1994 if(params.contains(reg3))
1995 pad = (reg3.capturedTexts()[1]).toInt();
1996 QRegExp reg4(
"space=(\\d+)");
1997 if(params.contains(reg4))
1998 space = (reg4.capturedTexts()[1]).toInt();
2001 if(params.contains(
"fullwidth"))
2002 fullwidth =
" width=\"100%\" ";
2004 if(!params.contains(
"notable"))
2005 xmlw.
beginNode(
"table",QString(
"cellpadding=%1 cellspacing=%2 border=%3 %4")
2012 if(!params.contains(
"noheader"))
2015 for(i = 0 ; i < col_count ; ++i)
2019 "align=\"center\" " :
2020 QString(
"align=\"center\" width=%1").arg(all_width));
2026 QString rowparameter;
2028 bool contains_cellalign;
2029 bool contains_addcellparam;
2030 QString precell,postcell;
2031 QString cellparameters;
2034 int expanding_num=0;
2049 contains_cellalign =
false;
2050 contains_addcellparam =
false;
2053 QRegExp regc(
"backgroundColor=(......)");
2056 rowparameter +=
" bgcolor=\"#"+regc.capturedTexts()[1] +
"\"";
2063 QRegExp regc(
"precell=([^;]+);");
2066 precell = regc.capturedTexts()[1];
2071 QRegExp regc(
"postcell=([^;]+);");
2074 postcell = regc.capturedTexts()[1];
2082 QRegExp regc(
"expandCol=(\\d+)-(\\d+)");
2085 posinstr = fpos + regc.matchedLength();
2086 from[expanding_num] = regc.capturedTexts()[1].toInt();
2087 to[expanding_num] = regc.capturedTexts()[2].toInt();
2090 if(expanding_num > 11)
2092 error(
"HPlainDataMatrix::getContentAsHtml: Too much expandCol parameter!");
2099 contains_cellalign =
true;
2102 contains_addcellparam =
true;
2108 for(i = 0 ; i < col_count ; ++i)
2112 if(fcc_mode && i == 0)
2114 xmlw.
putCData(
"td",precell+lst[i]+postcell,QString(
"colspan=%1 align=\"center\"").arg(col_count) );
2118 cellparameters =
"";
2121 cellparameters += QString(
" width=%1").arg(all_width);
2123 for(ii=0;ii < expanding_num;++ii)
2125 if(from[ii] == i && ((to[ii]-from[ii]) > 0))
2127 cellparameters += QString(
" colspan=%1").arg(1+to[ii]-from[ii]);
2131 if(from[inExpand] >= 0 && i > from[inExpand] && i <= to[inExpand])
2136 if(contains_cellalign)
2138 QRegExp regc1(QString(
"alignCellRight=%1\\s").arg(i));
2140 cellparameters +=
" align=\"right\"";
2142 QRegExp regc2(QString(
"alignCellCenter=%1\\s").arg(i));
2144 cellparameters +=
"align=\"center\"";
2147 if(contains_addcellparam)
2149 QRegExp regc(QString(
"addCellParam=%1:([^;]+);").arg(i));
2151 cellparameters +=
" " + regc.capturedTexts()[1];
2154 xmlw.
putCData(
"td",precell+lst[i]+postcell,cellparameters);
2160 if(!params.contains(
"notable"))
2162 if(params.contains(
"center"))
2164 if(params.contains(
"html"))
2185 HDataField_List::HDataField_List(
void)
2192 HDataField_List::~HDataField_List(
void)
2203 void HDataField_List::addElement(
HDataField *d)
2214 QString(
"Cannot insert a new element to the table,"
2215 " because It already has some connected field!\n"
2216 "Insert all own field first, than the connect the tables!"));
2219 next=
new HDataField_List();
2221 next->addElement(d);
2226 void HDataField_List::connectElement(HDataField_List *c)
2230 nextall->connectElement(c);
2238 void HDataField_List::disconnectElement(
void)
2240 if(next == NULL && nextall == NULL)
2244 else if(next == NULL && nextall != NULL)
2251 next->disconnectElement();
2255 void HDataField_List::clearElements(
void)
2282 imc_thattable = NULL;
2288 depend =
new QStringList();
2297 imc_thattable = NULL;
2302 depend =
new QStringList();
2314 tabletitle = x->tabletitle;
2316 sqlTable = x->sqlTable;
2337 sdebug(
"-->Dieing...HtableBase:"+sqlTable+
" __astala vista baby!");
2344 HDataField_List *tmp=table;
2347 if(tmp->data != NULL && tmp->data->sqlSelectHead() == sqln &&
2348 ( !all || tmp->data->conn_sqlTable == containerSqlTable
2366 HDataField_List *tmp=table;
2369 if(!tmp->data->isSQLField())
2393 HDataField_List *tmp=table;
2396 if(tmp->data != NULL &&
2397 tmp->data->getWhoami() ==
"HStatic" &&
2398 (title.isEmpty() || tmp->data->getTitleText() == title))
2411 depend->push_back(n);
2430 HDataField_List *run=NULL;
2433 table->disconnectElement();
2439 imc_thattable = NULL;
2442 for(run=table;run != NULL;run=run->next)
2443 run->data->connected =
false;
2449 HDataField_List *crun=NULL,*krun=NULL;
2454 if(crun->data != NULL)
2455 if(crun->data->getWhoami() ==
"HConnect")
2461 if(krun->data != NULL)
2462 if(krun->data->getWhoami() ==
"HKey")
2466 krun->data->sqlSelectHead(),
2467 type,connconstraint );
2484 if(crun->data != NULL)
2485 if(crun->data->getWhoami() ==
"HConnect")
2491 if(krun->data != NULL)
2492 if(krun->data->getWhoami() ==
"HKey")
2496 crun->data->sqlSelectHead(),
2497 type,connconstraint );
2509 emit
errorSignal(
"Automatic join fail: Can't find all necessary elements/part ");
2514 HDataField_List *run=NULL;
2516 sdebug(
"*** HTableBase::connectTable ***");
2517 if(type == INNER_JOIN || type == LEFT_OUTER_JOIN)
2519 conn_part.append(QString(
" %1 %2 ON %3.%4 = %5.%6%7 %8")
2520 .arg(QString((type == INNER_JOIN ?
"INNER JOIN" :
""))+
2521 QString((type == LEFT_OUTER_JOIN ?
"LEFT OUTER JOIN" :
"")))
2527 .arg(connconstraint.isEmpty() ?
"" : (
" AND " + connconstraint +
" "))
2532 table->connectElement(ct->table);
2536 ct->imc_thattable =
this;
2537 ct->imc_thatkey = thiskey;
2543 emit
errorSignal(QString(
"Unknown connection type: %1").arg(type));
2547 for(run=ct->table;run != NULL;run=run->next)
2548 run->data->connected =
true;
2550 sdebug(
"*** HTableBase::connectTable *** END");
2555 if(table != NULL)
delete table;
2564 table =
new HDataField_List();
2567 table->addElement(i);
2581 bool keyfound=
false;
2583 QString ret,keyname=
"",keyvalue=
"";
2585 HDataField_List *tmp=table;
2589 if(tmp->data->isSQLField())
2591 if(tmp->data->getWhoami() ==
"HSmallText" && tmp->data->sqlSelectHead() ==
"NON_SQL_LIST_SERIAL")
2600 if(tmp->data->getWhoami() ==
"HKey" && !keyfound)
2603 keyname = sqlTable+
"."+tmp->data->sqlSelectHead();
2604 keyvalue = tmp->data->getSQLValue();
2606 if(i != 0) ret.append(
",");
2608 if(!tmp->data->isEditable() && !tmp->data->getFunction().isEmpty())
2610 ret.append(tmp->data->getFunction() +
"("+( all ? (tmp->data->conn_sqlTable+
".") :
"" ) +
2611 tmp->data->sqlSelectHead()+
")");
2613 else if(!tmp->data->isEditable() && !tmp->data->getSubselect().isEmpty())
2615 ret.append(
"(" + tmp->data->getSubselect() +
")");
2619 ret.append(( all ? (tmp->data->conn_sqlTable+
".") :
"" ) +
2620 tmp->data->sqlSelectHead());
2630 ret.append(
" FROM " + sqlTable +
" " + (all ? (
conn_part+
" ") :
"") +
"WHERE ");
2632 if(keypart && keyname !=
"" && keyvalue !=
"")
2634 ret.append(
" "+keyname+
"="+keyvalue+
" ");
2638 ret.append(QString(
"%1 ").arg(
myInterface()->hsqli_truevalue));
2648 HDataField_List *tmp=table;
2653 if(tmp->data == NULL)
return QVariant(
"");
2654 else return tmp->data->sqlInsertHead();
2659 return QVariant(
"");
2664 HDataField_List *tmp=table;
2667 if(tmp->data != NULL)
2668 tmp->data->setColor(r,g,b);
2675 HDataField_List *tmp=table;
2678 if(tmp->data != NULL)
2679 tmp->data->setEditable();
2686 HDataField_List *tmp=table;
2689 if(tmp->data != NULL)
2690 tmp->data->notSet();
2697 HDataField_List *tmp=table;
2700 if(tmp->data != NULL)
2709 HDataField_List *tmp=table;
2724 sdebug(
"*** HTableBase::isChanged ***");
2725 HDataField_List *tmp=table;
2728 if(tmp->data != NULL)
2729 if(tmp->data->isSet())
2737 sdebug(
"*** HTableBase::isChanged *** END");
2743 sdebug(
"*** HTableBase::validate ***");
2748 HDataField_List *tmp=table;
2751 if(tmp->data != NULL)
2752 if( !((c = tmp->data->validate()).isEmpty()) )
2754 #ifdef VALIDATE_HALT_ON_FIRST_ERROR
2773 HDataField_List *tmp=table;
2776 if(tmp->data != NULL)
2777 tmp->data->setReadonly();
2784 HDataField_List *tmp=table;
2787 if(tmp->data != NULL)
2788 tmp->data->setHide();
2795 HDataField_List *tmp=table;
2798 if(tmp->data != NULL)
2799 tmp->data->setShow();
2810 HDataField_List *tmp=table;
2813 if(tmp->data != NULL && tmp->data->isShow() && ( what == 1 || tmp->data->isSQLField() ))
2815 l.push_back( (what == 1 ? tmp->data->getExplainText() : tmp->data->getTitleText()) );
2833 if(run == NULL)
return NULL;
2848 if(run == NULL)
return NULL;
2860 sdebug(
"*** HTableBase::dataUpdated ***");
2862 sdebug(
"*** HTableBase::dataUpdated *** END");
2878 if(
myInterface()->hsqli_need_create_sequence_before)
2883 str += QString(
"CREATE TABLE %1 \n (").arg(sqlTable);
2899 if(
myInterface()->hsqli_need_create_sequence_before)
2900 str.replace(
"_SEQNAME_",sqlTable+
"_pkey_sequence",Qt::CaseSensitive);
3041 df->
sqlSynced(dclog,forcechange,forcelog);
3108 sdebug(
"*** HTable::~HTable ***");
3110 sdebug(
"*** HTable::~HTable *** END");
3125 ro_mask = x->ro_mask;
3147 return QVariant(
"");
3154 sdebug(
"*** HTable::sqlUpdate ***");
3155 bool begin=
false,modified=
false,first=
false;
3158 QString ret=
"",part=
"",keyname=
"",keyvalue=
"";
3160 HDataField_List *tmp=table;
3161 for(;tmp != NULL;tmp=tmp->nextall)
3165 part=QString(
"UPDATE %1 SET ").arg(tmp->data->conn_sqlTable);
3171 if(tmp->data->isSQLField())
3173 if(tmp->data->getWhoami() ==
"HKey")
3175 keyname = tmp->data->sqlSelectHead();
3176 keyvalue = tmp->data->getSQLValue();
3179 if(tmp->data->getWhoami() ==
"HConnect")
3182 if( (tmp->data->isEditable() &&
3183 tmp->data->isSet() ) |
3184 (tmp->data->getWhoami() ==
"HTimestamp" &&
3185 ((
HTimestamp *)tmp->data)->is_checkenabled())
3192 if(tmp->data->getWhoami() !=
"HTimestamp")
3203 part.append(tmp->data->sqlUpdate());
3207 if(tmp->next == NULL)
3210 if(keyname ==
"" || keyvalue ==
"")
3212 sdebug(
"*** HTable::sqlUpdate *** END with empty string");
3216 part.append(
" WHERE "+keyname+
"="+keyvalue+
"; \n");
3221 sdebug(
"*** HTable::sqlUpdate *** ("+ret+
")");
3227 sdebug(
"*** HTable::sqlUpdate *** ("+ret+
")");
3234 HDataField_List *tmp=table;
3239 if(tmp->data == NULL)
return QVariant(
"");
3240 else return tmp->data->getValue();
3245 return QVariant(
"");
3252 if(intable.isEmpty())
3253 in_table = sqlTable;
3257 HDataField_List *tmp=table;
3260 if(tmp->data != NULL && tmp->data->getWhoami() ==
"HKey" && in_table == tmp->data->conn_sqlTable)
3264 return tmp->data->sqlSelectHead();
3268 return tmp->data->getValue().toString();
3278 HDataField_List *tmp=table;
3281 if(tmp->data != NULL && tmp->data->getWhoami() ==
"HKey")
3283 tmp->data->setValue(key);
3294 HDataField_List *tmp=table;
3297 sdebug(
"*** HTable::updateWithKey *** ");
3305 HDataField_List *refresh_tmp=table;
3306 while(refresh_tmp != NULL)
3308 if(refresh_tmp->data->getWhoami() ==
"HSqlChoose")
3309 ((
HSqlChoose *)refresh_tmp->data)->refreshSqlValues(
false,tdisabled);
3310 refresh_tmp=refresh_tmp->next;
3328 if((
myInterface()->hsqli_usequerysize && q->numRowsAffected() != 1) ||
3330 q->lastError().type() != QSqlError::NoError)
3334 errstr=(
"The SELECT returned with !=1 record! (1)\n>>"+((q->lastError()).text()));
3335 errstr+=
"\nQuery was: \""+sqlq+
"\"\n(Sql name of the table:"+sqlTable+
")\n";
3346 if(tmp->data != NULL && tmp->data->isSQLField())
3352 if(tmp->data->getWhoami() ==
"HTimestamp" && ((
HTimestamp *)tmp->data)->is_checkenabled() )
3355 tmp->data->setValue(q->value(idx),
true);
3356 tmp->data->notSet();
3374 sdebug(
"*** HTable::updateWithKey *** END");
3380 sdebug(
"*** HTable::returnToDefault ***");
3381 HDataField_List *tmp=table;
3384 if(tmp->data != NULL)
3387 tmp->data->notSet();
3388 dv = tmp->data->getDefaultValue();
3389 tmp->data->setDefval(dv);
3390 tmp->data->resetValidateStatus();
3397 sdebug(
"*** HTable::returnToDefault *** END");
3405 HDataField_List *tmp=table;
3406 QString ts_new=
"empty";
3407 QString ts_old=
"empty";
3409 sdebug(
"*** HTable::saveRecord *** ");
3413 sdebug(
"*** HTable::saveRecord *** ERROR1");
3423 if(tmp->data != NULL &&
3424 tmp->data->isSQLField() &&
3425 tmp->data->getWhoami() ==
"HTimestamp" &&
3426 ((
HTimestamp *)tmp->data)->is_checkenabled() &&
3430 QString sqlq=QString(
"SELECT %1 FROM %2 WHERE %3=\'%4\';")
3431 .arg(tmp->data->sqlSelectHead())
3432 .arg(tmp->data->conn_sqlTable)
3433 .arg(
getKey(HEAD,tmp->data->conn_sqlTable))
3434 .arg(
getKey(VALUE,tmp->data->conn_sqlTable));
3436 ts_old = tmp->data->getValue().toString();
3443 if((
myInterface()->hsqli_usequerysize && q->numRowsAffected() != 1 ) ||
3445 q->lastError().type() != QSqlError::NoError)
3450 errstr=(
"The SELECT returned with !=1 record! (TimeStamp Check- GetTimeStamp)\n>>"+
3451 ((q->lastError()).text()));
3455 sdebug(
"*** HTable::saveRecord *** ERROR2");
3458 ts_new = q->value(0).toString();
3461 if(ts_old != ts_new)
3467 errstr=QString(
"The data of the record is out of date in table \"%1 : %2\"!"
3468 "\nUpdate aborted! \n"
3469 "(The record has utomatically re-loaded try again the operation!)")
3470 .arg(tmp->data->conn_sqlTable)
3471 .arg(tmp->data->sqlSelectHead());
3476 sdebug(
"*** HTable::saveRecord *** ERROR3");
3497 sdebug(
"There is no relevant changes:emtpty update generated, exiting.");
3507 if(qu->lastError().type() != QSqlError::NoError)
3511 errstr=(
"An error occured during the update! :-(\n>>"+((qu->lastError()).text()));
3512 sdebug(
"SQLERROR: "+qu->lastError().text());
3515 sdebug(
"*** HTable::saveRecord *** ERROR4");
3527 dclog->setChangedKey(
getKey(
false));
3532 dclog->setTablename(
"EMPTY");
3533 dclog->setChangedKey(
"");
3541 dclog->writeOut(tdisabled);
3543 sdebug(
"*** HTable::saveRecord *** END");
3552 sdebug(
"*** HTable::insertRecord ***");
3570 if(qi->lastError().type() != QSqlError::NoError)
3575 errstr=(
"An error occured during the insert!\n>>"+((qi->lastError()).text()));
3585 insertedKey = getKeyValueAfterInsert();
3586 if(query_error_occured)
3588 query_error_occured =
false;
3593 emit
errorSignal(
"Error in HTable::getKeyValueAfterInsert !");
3604 if(resetafterinsert)
3610 sdebug(
"*** HTable::insertRecord *** END");
3618 sdebug(
"*** HTable::insertRecordAll ***");
3637 if(qi->lastError().type() != QSqlError::NoError)
3642 errstr=(
"An error occured during the insert!\n>>"+((qi->lastError()).text()));
3656 sdebug(
"*** HTable::insertRecordAll *** END");
3665 HDataField_List *tmp=table;
3666 ret =
"INSERT INTO "+sqlTable+
"(";
3667 for(;tmp != NULL;tmp=tmp->next)
3669 if(!insertkey && (tmp->data->getWhoami() ==
"HKey"))
continue;
3670 if(tmp->data->isSQLField())
3672 if(i != 0) ret.append(
",");
3673 ret.append(tmp->data->sqlInsertHead());
3677 ret.append(
") VALUES(");
3680 for(;tmp != NULL;tmp=tmp->next)
3682 if(!insertkey && (tmp->data->getWhoami() ==
"HKey"))
continue;
3683 if(tmp->data->isSQLField())
3685 if(i != 0) ret.append(
",");
3686 ret.append(tmp->data->sqlInsertValue());
3700 HDataField_List *run,*mainrun=table;
3702 QStringList *inserts =
new QStringList();
3703 QStringList *dependency =
new QStringList();
3704 QStringList *tablenames =
new QStringList();
3705 QList<bool> *done =
new QList<bool>();
3709 dependency->clear();
3710 tablenames->clear();
3711 while(mainrun != NULL)
3716 if(run->data == NULL)
3719 sdebug(
"ERROR : Internal error!");
3722 tname = run->data->conn_sqlTable;
3726 insert.append(
"INSERT INTO "+run->data->conn_sqlTable+
"(");
3727 for(;run != NULL;run=run->next)
3729 if(run->data == NULL)
3732 sdebug(
"ERROR : Internal error!");
3735 if(run->data->getWhoami() ==
"HKey")
3741 if(run->data->isSQLField())
3743 if(i != 0) insert.append(
",");
3744 insert.append(run->data->sqlInsertHead());
3748 insert.append(
") VALUES(");
3751 for(run=mainrun;run != NULL;run=run->next)
3753 if(run->data->getWhoami() ==
"HKey")
3758 if(run->data->getWhoami() ==
"HConnect")
3760 if(i != 0) insert.append(
",");
3761 insert.append(specifyKey(((
HConnect *)run->data)->getConnectedTable()));
3763 dep = ((
HConnect *)run->data)->getConnectedTable();
3767 if(run->data->isSQLField())
3769 if(i != 0) insert.append(
",");
3770 insert.append(run->data->sqlInsertValue());
3778 inserts->push_back(insert);
3779 tablenames->push_back(tname);
3780 dependency->push_back(dep);
3781 done->push_back(
false);
3784 while(mainrun->next != NULL)
3785 mainrun=mainrun->next;
3786 mainrun=mainrun->nextall;
3797 sdebug(
"Start dependency analysing...");
3803 for(i=0;i<(int)dependency->size();++i)
3804 if( (*dependency)[i] ==
"NULL")
3807 insert.append((*inserts)[i] +
"; \n");
3810 ttl=done->size()*done->size();
3813 sdebug(QString(
"next-round ttl:%1").arg(ttl));
3816 for(i=0;i<(int)done->size();++i)
3823 for(i=0;i<(int)dependency->size();++i)
3825 for(j=0;j<(int)dependency->size();++j)
3827 if( (*dependency)[i] == (*tablenames)[j] )
3831 insert.append((*inserts)[i] +
"; \n");
3838 sdebug(
"ERROR : INSERT: dependency error!");
3852 QString HTable::getKeyValueAfterInsert(
void)
3854 sdebug(
"*** HTable::getKeyValueAfterInsert ***");
3855 QString result,query,keyname=
"",timestampname=
"";
3857 HDataField_List *tmp=table;
3858 for(;tmp != NULL;tmp=tmp->nextall)
3860 if(tmp->data->isSQLField())
3862 if(tmp->data->getWhoami() ==
"HKey")
3863 keyname = tmp->data->sqlSelectHead();
3864 if(tmp->data->getWhoami() ==
"HTimestamp" && ((
HTimestamp *)tmp->data)->is_checkenabled())
3865 timestampname = tmp->data->sqlSelectHead();
3869 if(timestampname.isEmpty())
3871 timestampname = keyname;
3874 query = QString(
"SELECT %1 FROM %2 ORDER BY %4 DESC LIMIT 1")
3877 .arg(timestampname);
3879 result =
submit1ResultQuery(query,
"Error in HTable::getKeyValueAfterInsert! Cannot get the keyvalue of the inserted record",
3882 sdebug(
"*** HTable::getKeyValueAfterInsert *** END");
3887 QString HTable::specifyKey(QString tablename)
3889 QString ret,keyname,spec,ts;
3890 HDataField_List *run=table;
3894 if(run->data != NULL && run->data->conn_sqlTable == tablename)
3900 emit
errorSignal(
"Cannot connect tables: Cant find table"+tablename);
3908 for(;run != NULL;run = run->next)
3910 if(run->data != NULL && run->data->getWhoami() ==
"HKey")
3912 keyname = run->data->sqlSelectHead();
3915 if(run->data != NULL && run->data->getWhoami() ==
"HTimestamp")
3917 ts = run->data->sqlSelectHead();
3921 if(run->data != NULL && run->data->isSQLField())
3924 spec.append(
" AND ");
3925 spec.append(run->data->sqlSelectHead() +
"="+run->data->getSQLValue());
3929 ret=QString(
"( SELECT %1 FROM %2 WHERE %3 %4 LIMIT 1)")
3933 .arg( (ts.isEmpty() ?
"" : (
" ORDER BY "+ts+
" DESC")) );
3949 sdebug(
"*** HFloatTables::HFloatTables ***");
3958 emit
errorSignal(
"Error: NULL baserecord passed...");
3959 sdebug(
"Error in HFloatTables::HFloatTables : NULL baserecord passed...");
3964 sts =
new QList<int>();
3965 tbls =
new QList<HTable *>();
3968 titer=tbls->begin();
3970 sdebug(
"*** HFloatTables::HFloatTables *** END");
3976 QList<HTable *>::iterator i;
3978 while(i !=
tbls->end())
3988 titer=
tbls->begin();
3995 sdebug(
"*** HFloatTables::~HFloatTables ***");
4000 sdebug(
"*** HFloatTables::~HFloatTables *** END");
4007 titer=
tbls->begin();
4019 titer=
tbls->begin();
4023 while(titer !=
tbls->end())
4025 if(*siter == FLOATTABLES_STS_ALIVE || *siter == FLOATTABLES_STS_NEW)
4058 QList<int>::iterator si;
4060 while(si !=
sts->end())
4062 if(*si == FLOATTABLES_STS_ALIVE)
4063 *si = FLOATTABLES_STS_NEW;
4070 return sts->count();
4079 QList<int>::iterator si;
4081 while(si !=
sts->end())
4083 if(*si == FLOATTABLES_STS_ALIVE || *si == FLOATTABLES_STS_NEW)
4092 QList<int>::iterator si;
4093 QList<HTable *>::iterator ti;
4097 while(ti !=
tbls->end())
4099 if(*si == FLOATTABLES_STS_ALIVE || *si == FLOATTABLES_STS_NEW)
4100 if( ((*ti)->fieldBySqlName(field))->getValue().toString() == key )
4110 QList<int>::iterator si;
4111 QList<HTable *>::iterator ti;
4115 while(ti !=
tbls->end())
4117 if(*si == FLOATTABLES_STS_ALIVE || *si == FLOATTABLES_STS_NEW)
4118 if( (*ti)->getKey(
false) == key)
4129 QList<int>::iterator si;
4130 QList<HTable *>::iterator ti;
4135 while(ti !=
tbls->end())
4137 if(*si == FLOATTABLES_STS_ALIVE || *si == FLOATTABLES_STS_NEW)
4155 tbls->push_back(newrec);
4156 sts->push_back(FLOATTABLES_STS_NEW);
4167 tbls->push_back(newrec);
4168 sts->push_back(FLOATTABLES_STS_UNDEF);
4175 sdebug(
"*** HFloatTables::markedRecordToNew ***");
4176 QList<int>::iterator si;
4177 QList<HTable *>::iterator ti;
4181 while(ti !=
tbls->end())
4184 if( *si == FLOATTABLES_STS_UNDEF || *si == FLOATTABLES_STS_ALIVE)
4186 *si = FLOATTABLES_STS_NEW;
4187 sdebug(
"WHOAMI:"+(*ti)->getWhoami());
4188 sdebug(
"*** HFloatTables::markedRecordToNew *** END.OK");
4194 sdebug(
"*** HFloatTables::markedRecordToNew *** END.NOTFOUND");
4199 sdebug(
"*** HFloatTables::removeUndef ***");
4200 QList<int>::iterator si;
4201 QList<HTable *>::iterator ti;
4205 while(ti !=
tbls->end())
4207 if(*si == FLOATTABLES_STS_UNDEF)
4210 *si = FLOATTABLES_STS_CANCELLED;
4215 sdebug(
"*** HFloatTables::removeUndef *** END");
4220 QList<int>::iterator si;
4221 QList<HTable *>::iterator ti;
4225 while(ti !=
tbls->end())
4227 if(*si == FLOATTABLES_STS_ALIVE || *si == FLOATTABLES_STS_NEW)
4231 if(*si == FLOATTABLES_STS_ALIVE)
4232 *si = FLOATTABLES_STS_DELETED;
4233 if(*si == FLOATTABLES_STS_NEW)
4234 *si = FLOATTABLES_STS_CANCELLED;
4251 sdebug(
"*** HFloatTables::readDBTable ***");
4260 qs = QString(
"SELECT %1 FROM %2 WHERE %3 %4;")
4270 if(q->lastError().type() != QSqlError::NoError)
4276 emit
errorSignal(
"Error: Cannot exec the query in HFloatTables::readDBTable!");
4282 keys.push_back(q->value(0).toString());
4286 QStringList::iterator i;
4288 while(i != keys.end())
4294 sts->push_back(FLOATTABLES_STS_ALIVE);
4309 sdebug(
"*** HFloatTables::readDBTable ***END");
4315 sdebug(
"*** HFloatTables::saveDBTable ***");
4317 QList<int>::iterator si;
4318 QList<HTable *>::iterator ti;
4325 while(ti !=
tbls->end())
4329 case FLOATTABLES_STS_UNDEF:
4331 case FLOATTABLES_STS_CANCELLED:
4333 case FLOATTABLES_STS_ALIVE:
4334 if((*ti)->isChanged())
4335 if((*ti)->saveRecord(
false,
true))
4339 emit
errorSignal(
"Cannot update a HFloatTable record(Status:ALIVE): "+ (*ti)->errstr );
4343 case FLOATTABLES_STS_NEW:
4344 (*ti)->rereadNextInsertedKey();
4345 if((*ti)->insertRecord(
false,
true))
4349 emit
errorSignal(
"Cannot insert a HFloatTable record(Status:NEW): "+ (*ti)->errstr );
4352 k = (*ti)->getInsertedKey();
4354 if((*ti)->updateWithKeyAll(k,
true,
true))
4358 emit
errorSignal(
"Cannot reread an inserted new record: "+ (*ti)->errstr );
4362 *si = FLOATTABLES_STS_ALIVE;
4364 case FLOATTABLES_STS_DELETED:
4367 .arg((*ti)->getKey(
true))
4368 .arg((*ti)->getKey(
false)),
"Err",
true))
4377 *si=FLOATTABLES_STS_CANCELLED;
4388 sdebug(
"*** HFloatTables::saveDBTable *** END");
4399 sdebug(
"*** HList::HList ***");
4403 keys =
new QStringList();
4404 values =
new QList<QStringList *> ();
4413 query_valiter = values->begin();
4414 query_keyiter = keys->begin();
4416 sdebug(
"*** HList::HList *** END");
4421 sdebug(
"*** HList::~HList ***");
4427 for(QList<QStringList *>::iterator it = values->begin();it != values->end();++it)
4431 sdebug(
"*** HList::~HList *** END");
4440 keys =
new QStringList();
4441 values =
new QList<QStringList *> ();
4459 active_key = x->active_key;
4465 for(QList<QStringList *>::iterator it = x->values->begin();it != x->values->end();++it)
4474 sdebug(
"*** HList::captureNotify ***");
4475 QStringList::iterator i;
4477 sdebug(QString(
" %1 == %2").arg(tblname).arg(sqlTable));
4478 if(tblname == sqlTable)
4480 i = depend->begin();
4481 while(i != depend->end())
4492 sdebug(
"*** HList::clearList ***");
4493 for(QList<QStringList *>::iterator it = values->begin();it != values->end();++it)
4499 sdebug(
"*** HList::clearList *** END");
4505 sdebug(
"*** HList::actLine ***");
4507 sdebug(
"*** HList::actLine *** END");
4513 sdebug(
"*** HList::alternateActLine ***");
4515 sdebug(
"*** HList::alternateActLine *** END");
4522 HDataField_List *tmp=table;
4525 if(tmp->data->isSQLField() && tmp->data->isShow())
4527 if(tmp->data->sqlSelectHead() == sqln)
4531 row = (*values)[getIndexOf(*keys,active_key)];
4544 sdebug(
"*** HList::readList ***");
4549 QStringList *row_values;
4552 #ifdef PROGRESS_POSSIBILITY
4556 for(QList<QStringList *>::iterator it = values->begin();it != values->end();++it)
4564 HDataField_List *refresh_tmp=table;
4565 while(refresh_tmp != NULL)
4567 if(refresh_tmp->data->getWhoami() ==
"HSqlChoose")
4568 ((
HSqlChoose *)refresh_tmp->data)->refreshSqlValues(
false);
4569 refresh_tmp=refresh_tmp->next;
4573 #ifdef PROGRESS_POSSIBILITY
4578 HDataField_List *tmp=NULL;
4596 if(q->lastError().type() != QSqlError::NoError)
4598 #ifdef PROGRESS_POSSIBILITY
4603 errstr=(
"An error occured during the reading of list!\n>>"+((q->lastError()).text()));
4606 sdebug(
"*** HList::readList *** END");
4614 #ifdef PROGRESS_POSSIBILITY
4621 row_values=
new QStringList();
4625 if(tmp->data != NULL && tmp->data->isSQLField())
4627 if(tmp->data->getWhoami() ==
"HSmallText" && tmp->data->sqlSelectHead() ==
"NON_SQL_LIST_SERIAL")
4629 row_values->push_back( QString(
"%1").arg(serial++) );
4637 if(tmp->data->getWhoami() ==
"HKey" && row_key.isEmpty())
4639 row_key = q->value(idx).toString();
4641 if(tmp->data->isShow())
4643 row_values->push_back( tmp->data->dbValueToDispValue(q->value(idx)).toString() );
4655 values->push_back(row_values);
4656 keys->push_back(row_key);
4659 sdebug(QString(
"Fetched %1 values %2 keys.")
4660 .arg(values->size())
4661 .arg(keys->size()));
4666 #ifdef PROGRESS_POSSIBILITY
4672 #ifdef PROGRESS_POSSIBILITY
4676 sdebug(
"*** HList::readList *** END");
4683 HDataField_List *tmp=table;
4686 if(tmp->data->isSQLField() && tmp->data->isShow())
4690 if(tmp->data == NULL)
return QString(
"");
4691 else return tmp->data->getTitleText();
4708 sdebug(
"*** HList::setActiveKey to "+k);
4714 query_valiter = values->begin();
4715 query_keyiter = keys->begin();
4722 if(query_valiter == values->end() ||
4723 query_keyiter == keys->end())
4746 if(query_keyiter != keys->end())
4747 return (*query_keyiter);
4753 if(query_valiter != values->end())
4754 return (*query_valiter);
4764 :
HList(memt->sqlTableName())
4766 sdebug(
"*** HFloatTablesAsHList::HFloatTablesAsHList ***");
4773 if(templ == NULL && clone_struct_from_memt)
4779 sdebug(
"*** HFloatTablesAsHList::HFloatTablesAsHList *** END");
4784 sdebug(
"*** HFloatTablesAsHList::~HFloatTablesAsHList ***");
4786 sdebug(
"*** HFloatTablesAsHList::~HFloatTablesAsHList *** END");
4793 sdebug(
"active_key:"+active_key);
4802 QList<HTable *>::iterator ti;
4803 QList<int>::iterator si;
4807 QStringList *row_values;
4810 for(QList<QStringList *>::iterator it = values->begin();it != values->end();++it)
4816 HDataField_List *tmp=NULL;
4819 ti = mem->
tbls->begin();
4820 si = mem->
sts->begin();
4822 while(ti != mem->
tbls->end())
4824 if(*si == FLOATTABLES_STS_ALIVE || *si == FLOATTABLES_STS_NEW )
4828 row_values=
new QStringList();
4831 if(tmp->data != NULL && tmp->data->isSQLField())
4833 if(tmp->data->getWhoami() ==
"HSmallText" && tmp->data->sqlSelectHead() ==
"NON_SQL_LIST_SERIAL")
4835 row_values->push_back( QString(
"%1").arg(serial) );
4840 if(tmp->data->isShow())
4842 row_values->push_back(
4843 tmp->data->dbValueToDispValue(
4844 ((*ti)->fieldBySqlName(tmp->data->sqlSelectHead()))->getValue()
4855 keys->push_back(QString(
"temp_%1").arg(serial));
4856 values->push_back(row_values);
4885 sdebug(QString(
"Converted %1 values %2 keys.").arg(values->size()).arg(keys->size()));
4888 QString HFloatTablesAsHList::getSqlFieldValue(QString sqln)
4914 #ifdef PROGRESS_POSSIBILITY
4922 #ifdef PROGRESS_POSSIBILITY
4946 HDataFieldRole::~HDataFieldRole(
void)
4952 if(
mod.contains(
"hide;",Qt::CaseInsensitive))
4953 mod.replace(
"hide;",
"",Qt::CaseInsensitive);
4954 if(!
mod.contains(
"show;",Qt::CaseInsensitive))
4955 mod.prepend(
"show;");
4960 if(
mod.contains(
"show;",Qt::CaseInsensitive))
4961 mod.replace(
"show;",
"",Qt::CaseInsensitive);
4962 if(!
mod.contains(
"hide;",Qt::CaseInsensitive))
4963 mod.prepend(
"hide;");
4968 if(
mod.contains(
"readonly;",Qt::CaseInsensitive))
4969 mod.replace(
"readonly;",
"",Qt::CaseInsensitive);
4970 if(!
mod.contains(
"editable;",Qt::CaseInsensitive))
4971 mod.prepend(
"editable;");
4975 if(
mod.contains(
"editable;",Qt::CaseInsensitive))
4976 mod.replace(
"editable;",
"",Qt::CaseInsensitive);
4977 if(!
mod.contains(
"readonly;",Qt::CaseInsensitive))
4978 mod.prepend(
"readonly;");
4983 if(
mod.contains(
"guidisabled;",Qt::CaseInsensitive))
4984 mod.replace(
"guidisabled;",
"",Qt::CaseInsensitive);
4985 if(!
mod.contains(
"guienabled;",Qt::CaseInsensitive))
4986 mod.prepend(
"guienabled;");
4991 if(
mod.contains(
"guienabled;",Qt::CaseInsensitive))
4992 mod.replace(
"guienabled;",
"",Qt::CaseInsensitive);
4993 if(!
mod.contains(
"guidisabled;",Qt::CaseInsensitive))
4994 mod.prepend(
"guidisabled;");
4999 if(
mod.contains(
"setval;",Qt::CaseInsensitive))
5000 mod.replace(
"setval;",
"",Qt::CaseInsensitive);
5001 if(!
mod.contains(
"reset;",Qt::CaseInsensitive))
5002 mod.prepend(
"reset;");
5007 if(
mod.contains(
"reset;",Qt::CaseInsensitive))
5008 mod.replace(
"reset;",
"",Qt::CaseInsensitive);
5009 if(!
mod.contains(
"setval;",Qt::CaseInsensitive))
5010 mod.prepend(
"setval;");
5015 if(
mod.contains(
"show;",Qt::CaseInsensitive))
5022 if(
mod.contains(
"hide;",Qt::CaseInsensitive))
5029 if(
mod.contains(
"editable;",Qt::CaseInsensitive))
5036 if(
mod.contains(
"readonly;",Qt::CaseInsensitive))
5043 if(
mod.contains(
"guienabled;",Qt::CaseInsensitive))
5050 if(
mod.contains(
"guidisabled;",Qt::CaseInsensitive))
5057 if(
mod.contains(
"reset;",Qt::CaseInsensitive))
5064 if(
mod.contains(
"setval;",Qt::CaseInsensitive))
5074 QString _tailstr,
bool _editable)
5098 lastvalidate_result =
false;
5099 permanentvalidate_result =
false;
5100 manual_validate_error =
"";
5105 wcell_print =
false;
5135 color_g = x->color_g;
5136 color_b = x->color_b;
5145 wcellw_print = x->wcellw_print;
5146 wcell_print = x->wcell_print;
5159 lastvalidate_result = x->lastvalidate_result;
5160 permanentvalidate_result = x->permanentvalidate_result;
5161 manual_validate_error = x->manual_validate_error;
5208 lastvalidate_result =
true;
5209 permanentvalidate_result = lastvalidate_result;
5210 manual_validate_error = message;
5218 sdebug(
"HDataField::setFunction - Function accepted");
5223 sdebug(QString(
"Warning: HDataField::setFunction - Function definitions rejected! (Cannot set function on \"%1\")")
5250 sdebug(
"HDataField::setSubselect - Subselect accepted");
5255 sdebug(QString(
"Warning: HDataField::setSubselect - Subselect definitions rejected! (Cannot set subselect on \"%1\")")
5266 if(!
valid.isEmpty())
5270 d =
"Regular Expression is invalid!";
5272 if( ! re.exactMatch(
getValue().toString()) )
5273 d = (
"ERROR: The \""+
explain+
"\" field contains not valid data: \""+
getValue().toString()+
"\" ! ");
5279 QStringList::iterator iter=
notvalid.begin();
5282 if(
getValue().toString() == *iter )
5283 d =
"ERROR: The \""+
explain+
"\" field contains a NOTVALID data: \""+
getValue().toString()+
"\" ! ";
5288 if(d.isEmpty() && !manual_validate_error.isEmpty())
5290 d = manual_validate_error;
5292 manual_validate_error =
"";
5300 lastvalidate_result =
false;
5302 lastvalidate_result =
true;
5304 permanentvalidate_result = lastvalidate_result;
5333 rx.setPattern(
"^DEFVAL_SQL\\((.*)\\)$");
5334 if(rx.indexIn(s) == -1 || rx.cap(1).isEmpty())
5347 if((
myInterface()->hsqli_usequerysize && q->numRowsAffected() != 1 ) ||
5349 q->lastError().type() != QSqlError::NoError)
5353 errstr=(
"The SELECT returned with !=1 record! (1)\n>>"+((q->lastError()).text()));
5374 QString _tailstr,
bool _editable)
5430 return QString(
"NULL");
5435 return QString(
"%1=NULL").arg(
sqlColumn);
5468 if(!pmarkers.isEmpty())
5474 if(
markers.contains(mark) > 0)
5491 roles.push_back(role);
5496 QList<HDataFieldRole>::iterator i =
roles.begin();
5497 while(i !=
roles.end())
5516 sdebug(
"*** HDataField::useRole ***");
5521 QList<HDataFieldRole>::iterator i =
roles.begin();
5522 while(i !=
roles.end())
5571 sdebug(QString(
"DEBUG DataChangeLog: %1 field: \"%2\" to \"%3\" ---")
5630 return new HKey(
this);
5636 value = v.toString();
5653 return QVariant(value);
5659 return QString(
"%1").arg(value);
5661 return QString(
"\'%1\'").arg(value);
5666 return QString(
"%1").arg(value);
5679 return QString(
"\'%1\'").arg(value);
5680 r = QString(
"%1").arg(value.toInt(&ok));
5682 return QString::null;
5689 return QString::null;
5704 type = QString(
"VARCHAR(%1)").arg(
myInterface()->hsqli_varcharhkeylength);
5708 return (QString(
"%1\t %2 %3")
5722 connected_table = connected_tablep;
5743 connected_table = x->connected_table;
5755 value = v.toString();
5773 return QVariant(value);
5778 return QString(
"\'%1\'").arg(value);
5783 return QString(
"%1").arg(value);
5794 return QString(
"NULL");
5795 return QString(
"\'%1\'").arg(value);
5800 return QString::null;
5814 type = QString(
"VARCHAR(%1)").arg(
myInterface()->hsqli_varcharhkeylength);
5818 return (QString(
"%1\t %2")
5835 initial_selected =
false;
5852 initial_selected = x->initial_selected;
5863 value = v.toString();
5872 return QVariant( v.toString() + (
tailstr.isEmpty() ?
"" : (
" " +
tailstr)) );
5884 return QVariant(value);
5889 return QString(
"\'%1\'").arg(value);
5894 return QString(
"%1").arg(value);
5904 return QString(
"\'%1\'").arg(value);
5909 return QString(
"%1=\'%2\'")
5922 return sqlColumn + QString(
"\t VARCHAR(%1)").arg(
myInterface()->hsqli_smalltext_varcharlength);
5964 value = v.toString();
5980 return QVariant(value);
5985 return QString(
"\'%1\'").arg(value);
5990 return QString(
"%1").arg(value);
5995 return QString(
"%1")
6001 return QString(
"\'%1\'")
6007 return QString(
"%1=\'%2\'")
6022 return sqlColumn + QString(
"\t VARCHAR(%1)").arg(
myInterface()->hsqli_largetext_varcharlength);
6031 QStringList k,QStringList v)
6070 return QVariant(
values[getIndexOf(
keys,v.toString())]);
6086 value = v.toString();
6102 return QVariant(value);
6107 return QString(
"\'%1\'").arg(value);
6112 return QString(
"%1").arg(value);
6122 return QString(
"\'%1\'").arg(value);
6127 return QString(
"%1=\'%2\'")
6134 return QString(
"%1")
6150 QStringList k,QStringList v)
6188 return QVariant(
values[getIndexOf(
keys,v.toString())]);
6204 value = (int)(v.toString().toDouble());
6220 return QVariant(value);
6225 return QString(
"%1").arg(value);
6230 return QString(
"%1").arg(value);
6240 return QString(
"%1").arg(value);
6245 return QString(
"%1=%2")
6252 return QString(
"%1")
6260 if(
myInterface()->hsqli_numbertypename ==
"NUMERIC")
6278 minimum = -10000000;
6296 minimum = x->minimum;
6297 maximum = x->maximum;
6307 return QVariant(QString(
"%1%2").arg(v.toInt()).arg(
tailstr.isEmpty() ?
"" : (
" "+
tailstr)));
6313 return QString(
"%1:Value lower than minimum!").arg(
sqlColumn);
6315 return QString(
"%1:Value higher than maximum!").arg(
sqlColumn);
6340 return QVariant(value);
6345 return QString(
"%1").arg(value);
6350 return QString(
"%1").arg(value);
6360 return QString(
"%1").arg(value);
6365 return QString(
"%1=%2").arg(
sqlColumn).arg(value);
6377 if(
myInterface()->hsqli_numbertypename ==
"NUMERIC")
6379 int i =(int)( ::log10((
double)maximum));
6380 return sqlColumn + QString(
"\t NUMERIC(%1,0)").arg(i+1);
6423 value = v.toString();
6431 return QVariant(value);
6441 return QString(
"NULL");
6480 HCheck::HCheck(QString sqlc,QString ex,QString tit,QString t,QString def,QString ts,QString fs)
6541 return QVariant(value);
6551 return QString(value ?
"TRUE" :
"FALSE");
6593 minimum = -10000000;
6614 minimum = x->minimum;
6615 maximum = x->maximum;
6616 dMminDf = x->dMminDf;
6617 dMmaxDf = x->dMmaxDf;
6618 dMgroup = x->dMgroup;
6628 return QVariant(
doubleToQString(v.toDouble(),dMminDf,dMmaxDf,dMgroup)
6643 return QString(
"%1: Value lower than minimum!").arg(
sqlColumn);
6645 return QString(
"%1: Value higher than maximum!").arg(
sqlColumn);
6653 value = v.toDouble();
6670 return QVariant(value);
6675 return QString(
"%1").arg(value,0,
'f');
6680 return QString(
"%1").arg(value,0,
'f');
6690 return QString(
"%1").arg(value,0,
'f');
6695 return QString(
"%1=%2").arg(
sqlColumn).arg(value,0,
'f');
6707 if(
myInterface()->hsqli_floattypename ==
"NUMERIC")
6709 int i =(int)( ::log10(maximum));
6710 return sqlColumn + QString(
"\t NUMERIC(%1,3)").arg(i+4);
6720 HDate::HDate(QString sqlc,QString ex,QString tit,QString def,
bool u_a,
bool unk)
6730 if(def.toUpper() ==
"NOW" )
6731 value = QDate::currentDate();
6732 else if(u_a && def.toUpper() ==
"UNKNOWN")
6735 value = QDate(2000,1,1);
6737 else if(u_a && def.toUpper() ==
"UNKNOWN_AND_NOW")
6740 value = QDate::currentDate();
6746 if(parsedDv.isEmpty())
6747 value = QDate(2000,1,1);
6749 value = QDate::fromString(parsedDv,Qt::ISODate);
6776 return new HDate(
this);
6791 if(
value.toString().isEmpty() ||
6792 value.toString() ==
"NULL" ||
6796 value = QDate(2000,1,1);
6805 if(v.toString().isEmpty() ||
6806 v.toString() ==
"NULL" )
6811 value = QDate(2000,1,1);
6820 value = QDate::fromString(v.toString(),
"yyyy-MM-dd");
6821 if(!
value.isValid())
6822 value = QDate::fromString(v.toString(),
"yyyy-M-d");
6836 if(v.toString().toUpper() ==
"NOW" )
6839 value = QDate::currentDate();
6841 else if(
u_alive && v.toString().toUpper() ==
"UNKNOWN" )
6844 value = QDate(2000,1,1);
6846 else if(
u_alive && v.toString().toUpper() ==
"UNKNOWN_AND_NOW")
6849 value = QDate::currentDate();
6853 value = QDate::fromString(
6865 return QVariant(
"");
6867 if(
value.toString().isEmpty() ||
6868 value.toString() ==
"NULL" ||
6872 return QVariant(QDate(2000,1,1));
6874 return QVariant(
value);
6879 if(
value.toString().isEmpty() ||
6880 value.toString() ==
"NULL" ||
6884 return QVariant(QDate(2000,1,1));
6886 return QVariant(
value);
6892 return QString(
"NULL");
6895 return QString(
"\'%1\'")
6896 .arg(
value.toString(
"yyyy-MM-dd"));
6898 return QString(
"\'%1-%2-%3\'")
6906 return QString(
"%1")
6907 .arg(
value.toString(
"yyyy-MM-dd"));
6922 return QString(
"%1=%2")
6937 return sqlColumn + QString(
"\t %1").arg(
"VARCHAR(32)");
6977 QString errorstr=
"Error!: Dont define timestamp type, currently unsupported by database (HSqlInterface";
7001 QString s = v.toString();
7002 return QVariant( s.replace(QChar(
'T'),QChar(
' ')) );
7008 value = v.toString();
7024 return QVariant(value);
7029 return QString(
"\'%1\'")
7035 return QString(
"%1")
7051 return QString(
"%1=%2")
7069 int nullhash(
const char *c)
7076 int charcodehash(
const char *c)
7078 return ((
int)(c[0]));
7081 int dropchar(
const char *c)
7083 int i,j,l=(int)strlen(c);
7086 char *m=
new char[l+1];
7088 for(i=0,j=0;i<l;++i)
7089 if(isdigit((
unsigned char)c[i]))
7102 QString ct,QString kf,QString sf,QString sfh,QString fp,QString op,QString inthash,
bool easyf)
7111 readed_reftable =
false;
7113 connected_table = ct;
7116 showed_field_head = sfh;
7139 popupdialog_title =
"";
7141 toolbarbutton_down_text =
"";
7165 connected_table = x->connected_table;
7166 key_field = x->key_field;
7167 showed_field = x->showed_field;
7168 showed_field_head = x->showed_field_head;
7169 filter_part = x->filter_part;
7170 order_part = x->order_part;
7189 maxhash = x->maxhash;
7190 popupdialog_title = x->popupdialog_title;
7195 readed_reftable =
false;
7205 sdebug(
"*** HSqlChoose::refreshSqlValues ***");
7206 QString showed_field_mod;
7216 sqlq = QString(
"SELECT %1,%2 FROM %3 WHERE %4 %5 %6;")
7218 .arg(showed_field_mod)
7219 .arg(connected_table)
7221 .arg( filter_part.isEmpty() ?
"" : (QString(
" AND ") +filter_part) )
7231 if(q->lastError().type() != QSqlError::NoError)
7236 errstr=(
"The SELECT returned with <=0 record! (1)\n>>"+((q->lastError()).text()));
7242 #ifdef PROGRESS_POSSIBILITY
7248 keys .push_back(q->value(0).toString());
7249 sepvalues.push_back(q->value(1).toString());
7250 values.push_back(q->value(1).toString().replace(
"|",
" "));
7252 #ifdef PROGRESS_POSSIBILITY
7259 sdebug(
"Finished query!");
7262 sdebug(QString(
"Building hash cache %1<-%2.%3 ...")
7264 if(
hash == dropchar)
sdebug(
" (Using dropchar)");
7265 else if(
hash == nullhash)
sdebug(
" (Using nullchar)");
7266 else if(
hash == charcodehash)
sdebug(
" (Using charcodehash)");
7267 else sdebug(
" (Using custom hash function)");
7274 maxhash =(int)( keys.size() *
HASHMUL);
7275 pairs =
new KVPair[ maxhash ];
7276 for(i=0;i<maxhash;++i)
7278 pairs[i].busy =
false;
7280 pairs[i].value =
"";
7283 QStringList::Iterator ik = keys.begin();
7284 QStringList::Iterator iv = values.begin();
7285 while(ik != keys.end())
7289 for(i=(*
hash)((*ik).toLocal8Bit().constData())%maxhash;pairs[i].busy;i = (i + 1) % maxhash);
7291 pairs[i].busy =
true;
7293 pairs[i].value = *iv;
7298 #ifdef PROGRESS_POSSIBILITY
7304 #ifdef PROGRESS_POSSIBILITY
7308 readed_reftable =
true;
7311 dataUpdatedSignal();
7322 if(v.toString() ==
"NULL" || v.toString().isEmpty())
7323 return QVariant(QString(
""));
7325 if(!readed_reftable)
7329 return QVariant(values[getIndexOf(keys,vs)]);
7332 end = i = (*hash)(vs.toLocal8Bit().constData())%maxhash;
7333 for( ; ((i+1) != end) ; i = (i + 1) % maxhash)
7334 if(pairs[i].key == vs)
7335 return QVariant(pairs[i].value);
7337 return QVariant(QString(
""));
7342 readed_reftable =
false;
7348 if(!readed_reftable)
7355 if(!readed_reftable)
7362 if(!readed_reftable)
7369 sdebug(
"*** HSqlChoose::setDefval ***");
7370 QString calculated_defval;
7374 calculated_defval =
defvalParser( v.toString() ).toString();
7382 if(!readed_reftable)
7385 QStringList::iterator it = keys.begin();
7386 while(it != keys.end())
7388 if(*it == calculated_defval)
7392 value = calculated_defval;
7393 sdebug(
"*** HSqlChoose::setDefval *** END");
7408 value = calculated_defval;
7412 sdebug(
"*** HSqlChoose::setDefval *** END");
7418 sdebug(
"*** HSqlChoose::setValue ***");
7420 if(v.toString().isEmpty())
7423 value = v.toString();
7432 return QVariant(value);
7438 return QString(
"NULL");
7440 return QString(
"\'%1\'").arg(value);
7445 return QString(
"%1").arg(value);
7456 return QString(
"NULL");
7457 return QString(
"\'%1\'").arg(value);
7462 return QString(
"%1=%2")
7464 .arg((value ==
"NULL" || value == NULL ?
"NULL" : (
"\'"+value+
"\'")));
7469 return QString(
"%1")
7520 return sqlColumn + QString(
"\t VARCHAR(%1) REFERENCES %2 MATCH FULL")
7522 .arg(connected_table);
7527 sdebug(
"*** HSqlChoose::setInernalHashFunction ***");
7529 if(hashname ==
"dropchar")
7532 sdebug(
"Hash function set to: DROPCHAR");
7534 if(hashname ==
"charcodehash")
7536 hash = charcodehash;
7537 sdebug(
"Hash function set to: CHARCODEHASH");
7540 if(hashname ==
"nullhash")
7543 sdebug(
"Hash function set to: NULLHASH");
7546 sdebug(
"*** HSqlChoose::setInernalHashFunction *** END");
7555 sdebug(
"*** HDataChangeLogger::HDataChangeLogger ***");
7556 whoami=
"HDataChangeLogger";
7558 curr_pos = startpos;
7559 curr_user = startuser;
7560 this->logtable = NULL;
7562 name =
"dclkey"; type =
"HKey";
7565 error(QString(
"HDataChangeLogger::HDataChangeLogger:"
7566 " Error, the \"logtable\" must contain a \"%1\" named field with \"%2\" type!").arg(name).arg(type));
7569 name =
"pos"; type =
"HSmallText";
7572 error(QString(
"HDataChangeLogger::HDataChangeLogger:"
7573 " Error, the \"logtable\" must contain a \"%1\" named field with \"%2\" type!").arg(name).arg(type));
7576 name =
"cuser"; type =
"HSmallText";
7579 error(QString(
"HDataChangeLogger::HDataChangeLogger:"
7580 " Error, the \"logtable\" must contain a \"%1\" named field with \"%2\" type!").arg(name).arg(type));
7583 name =
"sqltablename"; type =
"HSmallText";
7586 error(QString(
"HDataChangeLogger::HDataChangeLogger:"
7587 " Error, the \"logtable\" must contain a \"%1\" named field with \"%2\" type!").arg(name).arg(type));
7590 name =
"changedkey"; type =
"HSmallText";
7593 error(QString(
"HDataChangeLogger::HDataChangeLogger:"
7594 " Error, the \"logtable\" must contain a \"%1\" named field with \"%2\" type!").arg(name).arg(type));
7597 name =
"sqlfieldname"; type =
"HSmallText";
7600 error(QString(
"HDataChangeLogger::HDataChangeLogger:"
7601 " Error, the \"logtable\" must contain a \"%1\" named field with \"%2\" type!").arg(name).arg(type));
7604 name =
"oldvalue"; type =
"HSmallText";
7607 error(QString(
"HDataChangeLogger::HDataChangeLogger:"
7608 " Error, the \"logtable\" must contain a \"%1\" named field with \"%2\" type!").arg(name).arg(type));
7611 name =
"newvalue"; type =
"HSmallText";
7614 error(QString(
"HDataChangeLogger::HDataChangeLogger:"
7615 " Error, the \"logtable\" must contain a \"%1\" named field with \"%2\" type!").arg(name).arg(type));
7618 name =
"changetime"; type =
"HTimestamp";
7621 error(QString(
"HDataChangeLogger::HDataChangeLogger:"
7622 " Error, the \"logtable\" must contain a \"%1\" named field with \"%2\" type!").arg(name).arg(type));
7626 this->logtable = logtable;
7627 sdebug(
"*** HDataChangeLogger::HDataChangeLogger ***END");
7632 sdebug(
"*** HDataChangeLogger::~HDataChangeLogger ***");
7633 if(changes.count() > 0)
7635 sdebug(
"*** HDataChangeLogger::~HDataChangeLogger : WARNING! Unsaved data in the logger!");
7638 sdebug(
"*** HDataChangeLogger::~HDataChangeLogger ***END");
7641 void HDataChangeLogger::addChange(QString fieldname,QString oldval,QString newval)
7643 struct HOneDataChange odc;
7646 odc.user = curr_user;
7647 odc.tablename = curr_table;
7648 odc.changedkey = curr_ckey;
7649 odc.fieldname = fieldname;
7650 odc.oldvalue = oldval;
7651 odc.newvalue = newval;
7653 changes.push_back(odc);
7656 void HDataChangeLogger::writeOut(
bool tdisabled)
7660 c = changes.count();
7676 query_error_occured =
true;
7677 emit
errorSignal(
"Error: Can't write the logger table!");
7689 HDynTableElement::HDynTableElement(
int type,QString name,QString sqlname,QString rowName,QString colName,QString labels)
7691 if(type != HDYNELEMENT_STRING && type != HDYNELEMENT_DOUBLE)
7692 type = HDYNELEMENT_STRING;
7696 this->rowName = rowName;
7697 this->colName = colName;
7698 this->sqlname = sqlname;
7699 this->labels.clear();
7700 this->labels = labels.split(
"|",QString::SkipEmptyParts);
7706 int HDynTableElement::getType(
void)
7711 bool HDynTableElement::isNumeric(
void)
7713 if(type == HDYNELEMENT_DOUBLE)
7717 bool HDynTableElement::isTextual(
void)
7719 return !isNumeric();
7722 void HDynTableElement::setDoubleValue(
double d)
7724 if(type == HDYNELEMENT_STRING)
7725 textual_value = QString(
"%1").arg(d);
7727 if(type == HDYNELEMENT_DOUBLE)
7731 void HDynTableElement::setTextualValue(QString s)
7733 if(type == HDYNELEMENT_STRING)
7736 if(type == HDYNELEMENT_DOUBLE)
7740 d = s.toDouble(&ok);
7746 double HDynTableElement::getDoubleValue(
void)
7748 if(type == HDYNELEMENT_STRING)
7752 d = textual_value.toDouble(&ok);
7757 if(type == HDYNELEMENT_DOUBLE)
7758 return double_value;
7763 QString HDynTableElement::getTextualValue(
void)
7765 if(type == HDYNELEMENT_STRING)
7766 return textual_value;
7768 if(type == HDYNELEMENT_DOUBLE)
7769 return QString(
"%1").arg(double_value);
7774 void HDynTableElement::addLabel(QString l)
7777 labels.push_back(l);
7780 bool HDynTableElement::hasLabel(QString l)
7784 QList<QString>::iterator i=labels.begin();
7785 while(i != labels.end())
7807 QList<HDynTableElement>::const_iterator i = t.elements.begin();
7808 while(i != t.elements.end())
7815 HDynTable::~HDynTable(
void)
7824 QList<HDynTableElement>::const_iterator i = s.elements.begin();
7825 while(i != s.elements.end())
7835 elements.push_back(e);
7845 s.append(QString(
"%1%2=%3")
7846 .arg(first ?
"" :
",")
7857 QList<HDynTableElement>::iterator i = elements.begin();
7858 while(i != elements.end())
7870 QList<HDynTableElement>::iterator i = elements.begin();
7871 while(i != elements.end())
7874 i->setDoubleValue(value);
7882 QList<HDynTableElement>::iterator i = elements.begin();
7883 while(i != elements.end())
7886 i->setTextualValue(value);
7897 QList<HDynTableElement>::iterator i = elements.begin();
7898 while(i != elements.end())
7904 return i->getDoubleValue();
7916 QList<HDynTableElement>::iterator i = elements.begin();
7917 while(i != elements.end())
7923 return i->getTextualValue();
7932 QList<HDynTableElement>::iterator i = elements.begin();
7933 while(i != elements.end())
7935 if(i->rowName == r && i->colName == c)
7936 i->setDoubleValue(value);
7944 QList<HDynTableElement>::iterator i = elements.begin();
7945 while(i != elements.end())
7947 if(i->rowName == r && i->colName == c)
7948 i->setTextualValue(value);
7958 QList<HDynTableElement>::iterator i = elements.begin();
7959 while(i != elements.end())
7961 if(i->rowName == r && i->colName == c)
7965 return i->getDoubleValue();
7976 QList<HDynTableElement>::iterator i = elements.begin();
7977 while(i != elements.end())
7979 if(i->rowName == r && i->colName == c)
7983 return i->getTextualValue();
7992 internal_iterator = elements.begin();
7998 if(internal_iterator == elements.end())
8005 ++internal_iterator;
8010 return internal_iterator->name;
8015 return internal_iterator->rowName;
8020 return internal_iterator->colName;
8025 return internal_iterator->sqlname;
8030 return internal_iterator->labels;
8035 return internal_iterator->isNumeric();
8040 return internal_iterator->getDoubleValue();
8045 return internal_iterator->getTextualValue();
8050 internal_iterator->setDoubleValue(d);
8056 internal_iterator->setTextualValue(s);
8062 QList<HDynTableElement>::iterator i = elements.begin();
8063 while(i != elements.end())
8065 if(i->hasLabel(limitTo))
8068 i->setDoubleValue(0.0);
8070 i->setTextualValue(
"");
8080 QList<HDynTableElement>::iterator i = elements.begin();
8081 while(i != elements.end())
8083 if(i->hasLabel(limitTo))
8085 i->setDoubleValue(0.0);
8096 QList<HDynTableElement>::iterator i = elements.begin();
8097 while(i != elements.end())
8099 if(i->hasLabel(limitTo) && i->isNumeric() && !set)
8101 max = i->getDoubleValue();
8104 if(i->hasLabel(limitTo) && i->isNumeric() && i->getDoubleValue() >
max)
8105 max = i->getDoubleValue();
8115 QList<HDynTableElement>::iterator i = elements.begin();
8116 while(i != elements.end())
8118 if(i->hasLabel(limitTo) && i->isNumeric() && !set)
8120 min = i->getDoubleValue();
8123 if(i->hasLabel(limitTo) && i->isNumeric() && i->getDoubleValue() <
min)
8124 min = i->getDoubleValue();
8133 QList<HDynTableElement>::iterator i = elements.begin();
8134 while(i != elements.end())
8136 if(i->hasLabel(limitTo) && i->isNumeric())
8137 sum += i->getDoubleValue();
8145 QList<HDynTableElement>::iterator i = elements.begin();
8146 while(i != elements.end())
8148 if(i->hasLabel(limitTo) && i->isNumeric())
8149 i->setDoubleValue( i->getDoubleValue() - d );
8157 QList<HDynTableElement>::iterator i = elements.begin();
8158 while(i != elements.end())
8160 if(i->hasLabel(limitTo) && i->isNumeric())
8169 QList<HDynTableElement>::iterator i = elements.begin();
8170 while(i != elements.end())
8172 if(i->hasLabel(limitTo) && i->isNumeric())
8173 i->setDoubleValue( i->getDoubleValue() + d );
8181 QList<HDynTableElement>::iterator i = elements.begin();
8182 while(i != elements.end())
8184 if(i->hasLabel(limitTo) && i->isNumeric())
8193 QList<HDynTableElement>::iterator i = elements.begin();
8194 while(i != elements.end())
8196 if(i->hasLabel(limitTo) && i->isNumeric())
8197 i->setDoubleValue( i->getDoubleValue() * d );
8205 QList<HDynTableElement>::iterator i = elements.begin();
8206 while(i != elements.end())
8208 if(i->hasLabel(limitTo) && i->isNumeric())
8217 QList<HDynTableElement>::iterator i = elements.begin();
8218 while(i != elements.end())
8220 if(i->hasLabel(limitTo) && i->isNumeric())
8222 i->setDoubleValue( i->getDoubleValue() / d );
8230 QList<HDynTableElement>::iterator i = elements.begin();
8231 while(i != elements.end())
8233 if(i->hasLabel(limitTo) && i->isNumeric())
8238 i->setDoubleValue( i->getDoubleValue() / d );
8248 QList<HDynTableElement>::iterator i = elements.begin();
8249 while(i != elements.end())
8251 if(i->hasLabel(limitTo))
8261 QList<HDynTableElement>::iterator i = elements.begin();
8262 while(i != elements.end())
8302 QList<HDynTableElement>::iterator i = elements.begin();
8303 while(i != elements.end())
8309 return i->hasLabel(label);
8323 QString dpart=
"",vpart=
"";
8341 if(!additionaldefpart.isEmpty())
8343 if(!dpart.isEmpty())
8345 dpart.append(additionaldefpart);
8348 if(!additionalvaluepart.isEmpty())
8350 if(!vpart.isEmpty())
8352 vpart.append(additionalvaluepart);
8355 QString query = QString(
"INSERT INTO %1(%2) VALUES(%3);")
8367 sdebug(
"*** HDynTableSqlConnector::readSql ***");
8369 QString query=
"SELECT ";
8379 query.append(QString(
" FROM %1%2%3;")
8381 .arg(filterpart.isEmpty() ?
"" :
" WHERE ")
8400 sdebug(
"*** HDynTableSqlConnector::readSql ***END");
8409 sdebug(
"*** HDynTableSqlConnector::updateSql ***");
8411 QString query = QString(
"UPDATE %1 SET ").arg(tablename);
8418 query.append(
"=" );
8423 query.append(QString(
"%1%2;")
8424 .arg(filterpart.isEmpty() ?
"" :
" WHERE ")
8430 sdebug(
"*** HDynTableSqlConnector::updateSql *** END");
8439 cs = QString(
"CREATE TABLE %1 (").arg(tablename);
virtual QString sqlUpdate(void)
HDataField * nextFieldAll(void)
QString getValueAsString(void)
HDataField * nextField(void)
virtual QString getSQLValue(void)
virtual QString sqlUpdate(void)
void setCell(int row, int col, QVariant vdata)
double max(QString limitTo="")
QStringList & getKeys(void)
void setGuidisabled(void)
void setGuiDisabledAllMarked(QString mark)
QSqlDatabase workDB(void)
bool isChanged(bool all=false)
~HRefreshAgentNetserver(void)
HNumber(QString sqlc, QString ex, QString tit, QString t, QString def)
virtual QString sqlCreateStringPart(QString switches="")
virtual HDataField * get_clone(void)
QString sqlSelectAll(QString tail="")
QString sqlInsertAll(void)
QString hsqli_booleantypename
void enableEasyForm(void)
int errorPassSlot(QString err)
QString sqlSelectWkAll(QString tail="")
virtual QString sqlSelectHead(void)
void setMaulallyValidateError(QString message)
virtual QVariant getValue(void)
virtual QString sqlUpdate(void)
HRefreshAgentNetclient(QString server_ip)
void appendHPainDataMatrix(HPlainDataMatrix *tail)
QStringList & getSeparatedValues(void)
virtual int setDefval(QVariant v)
void setFunction(QString func)
virtual QString sqlInsertValue(void)
virtual HDataField * get_clone(void)
virtual QVariant getValue(void)
int insertRecordAll(bool disable_tr=false)
virtual QString getSQLValue(void)
void cloneSqlSettingsFrom(HSqlHandler *other)
static void setSqlMode(QString modename)
virtual int setValue(QVariant v, bool sdisabled=false)
virtual QString getSQLValueAsString(void)
int hsqli_largetext_varcharlength
void addRow(QList< QVariant > listdata, QString ctrl="")
virtual QString sqlInsertValue(void)
virtual QString sqlInsertHead(void)
void alternateActionOnRecord(QString key)
virtual QVariant dbValueToDispValue(QVariant v)
void setIndexedElementValue(int index, double d)
virtual int setDefval(QVariant v)
HFloating(QString sqlc, QString ex, QString tit, QString t, QString def)
HTable * createRecord(void)
virtual QString getSQLValueAsString(void)
virtual QVariant getValue(void)
QString getColumn(int col, QString separator)
QString currentElementColumnName(void)
static bool isConnected(void)
void blockReInitialize(QString hide_marker, QString ro_marker)
HTable * createRecordAsUndef(void)
virtual int setValue(QVariant v, bool sdisabled=false)
virtual QString sqlInsertHead(void)
static void setSqlModeBackToFirst(void)
QList< QVariant > currentRow(void)
QString getElementValueString(QString name, bool *found=NULL)
void clearSqlSynced(void)
HDataField * fieldBySqlName(QString sqln, bool all=false, QString containerSqlTable="")
void delRole(QString name)
HStatic(QString ex, QString tit="", QString def="")
int alternateActLine(void)
QString sqlCreateString(QString switches="")
HTable * getTByField(QString field, QString key)
virtual HDataField * get_clone(void)
virtual bool acceptSubselect(void)
void deepcopy_from(HDate *x)
void addition(double d, QString limitTo="")
virtual int setValue(QVariant v, bool sdisabled=false)
bool hasReadonlyMod(void)
QString sqlCreateString(QString switches="")
void emptyall(QString limitTo="")
int alternateActLine(QString key)
HPlainDataMatrix * submitNResultQuery(int N, QString q, QString err, bool tdisabled=false)
void setReadolnyAllMarked(QString mark)
virtual QString getSQLValue(void)
void deepcopy_from_htablebase(HTableBase *x)
void setTailText(QString tail)
virtual HDataField * get_clone(void)
void addRole(HDataFieldRole role)
void beginNode(QString n, QString parameters="")
virtual HDataField * get_clone(void)
virtual QString sqlInsertValue(void)
QString operator[](int i)
virtual QString getSQLValueAsString(void)
QString sqlTableName(void)
virtual HDataField * get_clone(void)
virtual QString getSQLValue(void)
QString dumpElements(void)
QVariant submit1ResultQuery(QString q, QString err, bool tdisabled=false)
virtual QString sqlSelectHead(void)
void sqlSynced(HDataChangeLogger *dclog=NULL, bool forcechange=false, bool forcelog=false)
virtual QString sqlInsertValue(void)
int(* hash)(const char *)
virtual QVariant dbValueToDispValue(QVariant v)
void setHideAllMarked(QString mark)
HDataField * fieldByIndex(int i, bool all=false)
void addMark(QString mark)
virtual HDataField * get_clone(void)
void setTitleText(QString titl)
bool submit0ResultQuery(QString q, QString err, bool tdisabled=false)
void disableControlSlot(void)
virtual QString lowerValidate(void)
double getElementValueDoubleByRowColName(QString r, QString c, bool *found=NULL)
double min(QString limitTo="")
void getnotify(QString tblname)
QVariant operator[](int i)
HKey(QString sqlc, QString ex, QString tit, QString def)
void value_is_unknown(void)
HDataField(QString _sqlColumn, QString _explain, QString tit, QString _tailstr="", bool _editable=true)
void resetValidateStatus()
virtual QString getSqlFieldValue(QString sqln)
QStringList & getValues(void)
virtual QVariant getValue(void)
HSqlSingleInterface * myInterface(void)
void deepcopy_from(HFloating *x)
void addGuienabledMod(void)
QString getContentAsHtml(QString params)
int countElements(QString limitTo="")
virtual int setValue(QVariant v, bool sdisabled=false)
virtual int setDefval(QVariant v)
QString hsqli_timestamptypename
virtual QString sqlCreateStringPart(QString switches="")
void refreshValuesKeys(bool updSignal=false)
virtual QString getSQLValue(void)
void removeCurrentRow(void)
int hsqli_varcharhkeylength
void setHeader(QList< QString > strlistdata)
void setSqlFieldValue(QString sqln, QVariant v, bool sdisable=false)
bool hsqli_appendsqlerrormsg
virtual QString sqlSelectHead(void)
void addDependTableName(QString n)
HRefreshAgentNetserver(void)
virtual QVariant dbValueToDispValue(QVariant v)
virtual int setDefval(QVariant v)
virtual QVariant getValue(void)
QString getKeyOfValue(QString s)
virtual QString sqlUpdate(void)
void dataUpdatedSignal(void)
virtual QString getSQLValueAsString(void)
void deepcopy_from(HConnect *x)
void divide(double d, QString limitTo="")
void removeSqlCooseButtons(void)
virtual QString sqlUpdate(void)
virtual QString sqlSelectHead(void)
void setAppendPrependColumn(int col, QString prepend, QString append)
void setHeaderCell(int col, QString strdata)
virtual QVariant dbValueToDispValue(QVariant v)
void addReadonlyMod(void)
QString currentElementValueString(void)
QString getElementSqlName(QString name)
QString getDefaultValue(void)
void blockReInitializeBase(QString hide_marker, QString ro_marker)
QSqlQuery * allocateQSqlQuery(void)
QStringList * queryNextValues(void)
virtual QString sqlCreateStringPart(QString switches="")
virtual QString sqlInsertValue(void)
virtual QString getSQLValue(void)
void deepcopy_from(HCheck *x)
HLargeText(QString sqlc, QString ex, QString tit, QString def)
void putRawData(QString data)
virtual QVariant dbValueToDispValue(QVariant v)
virtual QVariant getValue(void)
void addToolButton(const QObject *receiver, QString text)
virtual QString getSQLValue(void)
virtual QString sqlSelectHead(void)
void replaceTextInColumn(int col, QString find, QString replace, bool parts=false)
QString hsqli_timestampnowvalue
HCheck(QString sqlc, QString ex, QString tit, QString t, QString def, QString ts=GSAFETEXT_YES_HAVE, QString fs=GSAFETEXT_NO_HAVENOT)
double sumCoulmnAsDouble(int col)
void deepcopy_from(HLargeText *x)
int returnToDefault(void)
virtual QString sqlUpdate(void)
static HRefreshAgent * getNotifyAgent(void)
QStringList * queryCurrValues(void)
QString currentElementName(void)
virtual QString sqlInsertValue(void)
virtual QString sqlInsertValue(void)
virtual int setValue(QVariant v, bool sdisabled=false)
QString queryCurrKey(void)
QString currentElementRowName(void)
QList< HDataFieldRole > roles
virtual bool acceptFunction(void)
void setColor(int r, int g, int b)
bool elementHasLabel(QString name, QString label, bool *found=NULL)
int returnToDefault(bool all=true)
virtual int setDefval(QVariant v)
QVariant getCell(int row, int col)
virtual QString sqlSelectHead(void)
QString hsqli_sequence_creation_string
virtual QString getSQLValueAsString(void)
bool hsqli_hkeytype_varchar_int
int readDBTable(QString filter, bool tdisabled=false)
void addRowStrCTRL(QString ctrl, QString d1="", QString d2="", QString d3="", QString d4="", QString d5="", QString d6="", QString d7="", QString d8="", QString d9="", QString d10="", QString d11="", QString d12="", QString d13="", QString d14="", QString d15="")
virtual int setValue(QVariant v, bool sdisabled=false)
QString doubleToQString(double val, int min, int max, int group)
double dRound(double val, int mode)
void setCurrentElementValue(double d)
int refreshSqlValues(bool emitsignal=true, bool tdisabled=false)
void dataChangedNongui(void)
virtual QString getSQLValueAsString(void)
virtual int setValue(QVariant v, bool sdisabled=false)
bool hasGuidisabledMod(void)
virtual QString sqlUpdate(void)
virtual int setDefval(QVariant v)
virtual QString sqlSelectHead(void)
virtual QString sqlUpdate(void)
double getElementValueDouble(QString name, bool *found=NULL)
virtual int setValue(QVariant v, bool sdisabled=false)
double sum(QString limitTo="")
bool currentElementIsNumeric(void)
void removeExtraFunction(void)
QString getValueOfKey(QString s)
void setActiveKey(QString k)
void putCData(QString n, QString data, QString parameters="")
QString extrafunc_text[5]
virtual QString sqlInsertHead(void)
virtual int readList(QString filter="", bool all=true)
virtual int setDefval(QVariant v)
void useRole(QString name)
virtual QString sqlCreateStringPart(QString switches="")
int deleteRecord(HTable *d)
QString getHeaderItem(int col)
void sustraction(double d, QString limitTo="")
virtual QString sqlCreateStringPart(QString switches="")
HConnect(QString sqlc, QString connected_tablep)
void alternateActionOnRecord(QString key)
virtual QString sqlSelectHead(void)
virtual QString sqlCreateStringPart(QString switches="")
virtual QString sqlInsertValue(void)
QStringList * deep_copy_stringlist(QStringList *target, QStringList *source)
virtual QString sqlInsertValue(void)
virtual int clearList(void)
int updateWithKey(QString key="", bool all=false, bool update=true, bool tdisabled=false)
virtual QString getSQLValue(void)
virtual QVariant dbValueToDispValue(QVariant v)
QString sqlConcatenateToLocal(QString string)
virtual QString lowerValidate(void)
void errorSignal(QString err)
void deepcopy_from(HSqlChoose *x)
QVariant getSqlFieldValue(QString sqln)
void setElementValueByRowColName(QString r, QString c, double value)
void setFilterPart(QString fp)
void setSubselect(QString subs)
virtual QString sqlCreateStringPart(QString switches="")
HDataField * staticFieldByTitle(QString title="")
QString hsqli_numbertypename
virtual void value_changed()
void deepcopy_from_htable(HTable *x)
QString concatenateCoulmn(int col, QString separator)
virtual QString sqlInsertHead(void)
virtual int clearList(void)
HTable * nextRecord(void)
void addField(HDataField *i)
virtual QString getSQLValueAsString(void)
virtual QString sqlSelectHead(void)
void setExplainText(QString expl)
virtual QVariant dbValueToDispValue(QVariant v)
QString validate(bool all=true)
virtual QString lowerValidate(void)
virtual QString getSQLValue(void)
QList< QVariant > getRow(int row)
virtual QVariant getValue(void)
void setStream(QTextStream *oo)
QVariant operator[](int i)
static void notify(QString tblname)
void clearNotValidValues(void)
HTable * getActiveTable(void)
void updateStaticDisplayElementsSignal(void)
void setRowControl(int row, QString ctrl)
QString queryNextKey(void)
virtual QVariant getValue(void)
virtual QString getSQLValueAsString(void)
int updateWithKeyAll(QString key="", bool update=true, bool tdisabled=false)
void delRole(QString name)
virtual QVariant getValue(void)
HTable * getTByKey(QString key)
void setColorAllMarked(QString mark, int r, int g, int b)
QVariant defvalParser(QString s)
void setCellStr(int row, int col, QString strdata)
void putEmptyNode(QString n, QString parameters="")
void addExtraFunction(int pos, const QObject *receiver, QString text)
virtual HDataField * get_clone(void)
QString getValueOfKey(QString s)
virtual QString getSQLValueAsString(void)
virtual QString sqlCreateStringPart(QString switches="")
virtual int setDefval(QVariant v)
HTimestamp(QString sqlc, QString ex, QString tit, QString def, bool c)
virtual HDataField * get_clone(void)
virtual int setValue(QVariant v, bool sdisabled=false)
bool hsqli_need_create_sequence_before
void setElementValue(QString name, double value)
bool hsqli_sqlchooseconstraint
virtual HDataField * get_clone(void)
QTextStream * getStream(void)
void removeHTMLTags(bool force_all=false)
const QObject * extrafunc_receiver[5]
QString sqlUpdate(bool all=false)
void disableEasyForm(void)
HFloatTables(HTable *baserec)
QString getIndexedValueString(int index, bool *found=NULL)
void setNotValidValues(QStringList nvl)
virtual QString sqlSelectHead(void)
QList< QString > currentRowStr(void)
void cloneSqlInterfaceSettingsFrom(HSqlInterface *other)
HTable * getTByNum(int idx)
virtual int setDefval(QVariant v)
bool hsqli_largetext_sizemustdefine
void deepcopy_from(HNumber *x)
virtual int readList(QString filter="", bool all=true)
virtual QVariant dbValueToDispValue(QVariant v)
HSqlChoose(QString sqlc, QString ex, QString tit, QString def, QString ct, QString kf, QString sf, QString sfh, QString fp, QString op, QString inthash="", bool easyf=true)
virtual QString sqlUpdate(void)
QString hsqli_currentModeName
virtual QString sqlCreateStringPart(QString switches="")
QString currentRowControl(void)
virtual QString getSQLValueAsString(void)
double getIndexedValueDouble(int index, bool *found=NULL)
HDate(QString sqlc, QString ex, QString tit, QString def, bool u_a=true, bool unk=true)
virtual QString sqlInsertHead(void)
virtual QString sqlCreateStringPart(QString switches="")
void addRowStr(QList< QString > strlistdata, QString ctrl="")
virtual QString getSQLValueAsString(void)
virtual QString sqlSelectHead(void)
virtual QString sqlSelectHead(void)
virtual QString sqlSelectHead(void)
int sumCoulmnAsInt(int col)
void connectionEstablished()
HPlainDataMatrix(int col)
~HRefreshAgentNetclient()
virtual QString sqlCreateStringPart(QString switches="")
QList< QString > getRowStr(int row)
HCharHash(QString sqlc, QString ex, QString tit, QString t, QString def, QStringList k, QStringList v)
void markedRecordToNew(HTable *r)
virtual QVariant getValue(void)
virtual QString getSQLValue(void)
bool hasMark(QString mark)
virtual QString getSQLValue(void)
static HSqlSingleInterface * currentDefaultSqlInterface(void)
QStringList currentElementLabels(void)
void multiplicate(double d, QString limitTo="")
static void setCustomSqlDatabase(QString databaseName, QString sqlinterfacename="")
void setGuiEnabledAllMarked(QString mark)
void setShowAllMarked(QString mark)
virtual QString sqlInsertHead(void)
virtual int setValue(QVariant v, bool sdisabled=false)
virtual HDataField * get_clone(void)
virtual QString sqlInsertHead(void)
void setEditableAllMarked(QString mark)
void putHead(QString enc, bool nullhead=false)
void clearSqlSynced(void)
virtual QString getSQLValueAsString(void)
virtual QString sqlCreateStringPart(QString switches="")
void insertSql(QString additionaldefpart="", QString additionalvaluepart="")
void replaceSameUnderCellToEmpty(int col)
void removeToolButton(void)
void deepcopy_from(HStatic *x)
virtual int setValue(QVariant v, bool sdisabled=false)
virtual int setDefval(QVariant v)
virtual QVariant getKnownValue(void)
void setColor(int r, int g, int b)
virtual int setValue(QVariant v, bool sdisabled=false)
bool hsqli_hastimestamptype
void dataModifiedSignal(void)
QByteArray recodeData(QString d)
int my_dtoa(double v, char *buffer, int bufflen, int min, int max, int group)
virtual QString sqlSelectHead(void)
int captureNotify(QString tblname)
int hsqli_hackconvert_stdsqlconcatenation_to_local
void actionOnRecord(QString key)
void setInernalHashFunction(QString hashname)
QStringList allMarker(void)
void enableControlSlot(void)
int saveRecord(bool all=false, bool tdisabled=false)
virtual HDataField * get_clone(void)
void returnToDefaultAllMarked(QString mark)
virtual QString sqlInsertValue(void)
void sqlSynced(HDataChangeLogger *dclog=NULL, bool forcechange=false, bool forcelog=false)
virtual QVariant getValue(void)
void setLoggingAllMarked(QString mark)
static void setDefaultSqlDatabase(void)
virtual HDataField * get_clone(void)
virtual QVariant getValue(void)
QString indexedElementSqlName(int index)
HDataChangeLogger(HTable *logtable, QString startpos=GSAFETEXT_UNKNOWN, QString startuser=GSAFETEXT_UNKNOWN)
virtual QString getSQLValueAsString(void)
virtual int setDefval(QVariant v)
void deepcopy_from(HCharHash *x)
virtual QString sqlUpdate(void)
void deepcopy_from(HNumHash *x)
int hsqli_charhash_varcharlength
void connectTable(HTableBase *ct, int type=INNER_JOIN, QString connconstraint="")
virtual QString sqlInsertHead(void)
void setValidator(QString v="")
virtual QString sqlInsertHead(void)
QString getCellStr(int row, int col)
bool isReallyChanged(void)
HFloatTablesAsHList(HFloatTables *memt, HList *templ=NULL, bool clone_struct_from_memt=false)
virtual QString sqlInsertValue(void)
virtual int setValue(QVariant v, bool sdisabled=false)
virtual QString getSQLValue(void)
virtual QString sqlInsertValue(void)
void setAllField(QString fname, QVariant value)
bool hasEditableMod(void)
void addEditableMod(void)
QString indexedElementName(int index)
virtual int setDefval(QVariant v)
QString sqlSelectWk(QString tail="", bool all=false)
static HSqlSingleInterface * getSqlInterface(QString interfacename)
QString hsqli_hkeyconstraint
QStringList getHeads(int what)
virtual QString sqlCreateStringPart(QString switches="")
void dconsole_popup(QString t, QString txt)
virtual QVariant dbValueToDispValue(QVariant v)
virtual QString getSQLValue(void)
bool isReallyChanged(void)
void useRole(QString name)
virtual HDataField * get_clone(void)
virtual QString getSQLValueAsString(void)
QStack< HTableBase * > * connectedTableBases
QString getKey(bool head_val, QString intable="")
void setData(QString _sqlColumn, QString _explain, QString tit, QString _tailstr="", bool _editable=true)
virtual int setDefval(QVariant v)
void clearAndFreeConnections(void)
static QString serverAddress()
virtual QVariant getValue(void)
QString getElementValueStringByRowColName(QString r, QString c, bool *found=NULL)
void value_is_known(void)
virtual QString sqlInsertHead(void)
virtual QString sqlInsertHead(void)
HSmallText(QString sqlc, QString ex, QString tit, QString t, QString def)
void addNotValidValue(QString v)
virtual QVariant getValue(void)
virtual QString sqlInsertHead(void)
virtual QString getSQLValue(void)
virtual QString sqlInsertValue(void)
QString currentElementSqlName(void)
void deepcopy_from_hdatafield(HDataField *x)
QString sqlInsert(bool insertkey=false)
void deepcopy_from_hlist(HList *x)
HNumHash(QString sqlc, QString ex, QString tit, QString t, QString def, QStringList k, QStringList v)
void clearConnections(void)
int hsqli_smalltext_varcharlength
virtual int setValue(QVariant v, bool sdisabled=false)
QString sqlSelect(QString tail="", bool all=false, bool keypart=false)
virtual QString sqlInsertHead(void)
virtual QString sqlUpdate(void)
QString hsqli_datetypename
double currentElementValueDouble(void)
virtual QString sqlUpdate(void)
virtual int setDefval(QVariant v)
virtual QString sqlUpdate(void)
void actionOnRecord(QString key)
int fieldCount(bool withconnect=false)
void deepcopy_from(HSmallText *x)
void addGuidisabledMod(void)
void zeroall(QString limitTo="")
virtual QString sqlInsertValue(void)
QByteArray recodeDataNoconvert(QString d)
QString hsqli_floattypename
int insertRecord(bool insertkey=false, bool disable_tr=false, bool resetafterinsert=true)
virtual QString sqlUpdate(void)
virtual QString sqlCreateStringPart(QString switches="")
virtual QString sqlInsertHead(void)
static bool isRunning(void)
QString getKeyOfValue(QString s)
bool hasGuienabledMod(void)
QList< QString > getHeader(void)
bool queryNextRecord(void)
void deepcopy_from(HTimestamp *x)
int saveDBTable(bool tdisabled=false)
void deepcopy_from(HKey *x)