From: <ibr...@us...> - 2010-10-05 12:08:05
|
Revision: 3731 http://tora.svn.sourceforge.net/tora/?rev=3731&view=rev Author: ibre5041 Date: 2010-10-05 12:07:59 +0000 (Tue, 05 Oct 2010) Log Message: ----------- Modified Paths: -------------- branches/tora-trotl/src/tomodeleditor.cpp branches/tora-trotl/src/tooracleconnection.cpp branches/tora-trotl/src/toqvalue.h branches/tora-trotl/src/toresultmodel.cpp branches/tora-trotl/src/trotl/src/trotl_exc.cpp Modified: branches/tora-trotl/src/tomodeleditor.cpp =================================================================== --- branches/tora-trotl/src/tomodeleditor.cpp 2010-10-05 11:36:30 UTC (rev 3730) +++ branches/tora-trotl/src/tomodeleditor.cpp 2010-10-05 12:07:59 UTC (rev 3731) @@ -353,7 +353,7 @@ if(data.type() == QVariant::UserType) { toQValue::complexType *i = data.value<toQValue::complexType*>(); - setText(i->summary()); + setText(i->editData()); return; } Modified: branches/tora-trotl/src/tooracleconnection.cpp =================================================================== --- branches/tora-trotl/src/tooracleconnection.cpp 2010-10-05 11:36:30 UTC (rev 3730) +++ branches/tora-trotl/src/tooracleconnection.cpp 2010-10-05 12:07:59 UTC (rev 3731) @@ -78,6 +78,8 @@ #include <QString> #include <QTextStream> +static int toMaxLong = toConfigurationSingle::Instance().maxLong(); + static toSQL SQLComment("toOracleConnection:Comments", "SELECT Column_name,Comments FROM sys.All_Col_Comments\n" " WHERE Owner = :f1<char[100]>\n" @@ -159,8 +161,9 @@ { public: toOracleClob(trotl::OciConnection &_conn) - : toQValue::complexType(), - data(_conn) + : toQValue::complexType() + , data(_conn) + , _length(0) {}; /* virtual */ bool isBinary() const { @@ -170,14 +173,42 @@ { return true; } - /* virtual */ QString summary() const + + /* virtual */ QString displayData() const { + if(getLength() < toMaxLong) + { + ::trotl::SqlOpenLob clob_open(data, OCI_LOB_READONLY); + char buffer[toMaxLong]; + unsigned int bytes_read; + bytes_read = data.read(&buffer[0], sizeof(buffer), 1, sizeof(buffer)); + buffer[bytes_read] = '\0'; + return QString(buffer); + } + else + return QString("clob"); + } + + /* virtual */ QString editData() const + { + return QString("edit data Datape: Oracle [N]CLOB\n" + "Size: %1B\n").arg(getLength()); + } + + /* virtual */ QString userData() const + { return QString("Datape: Oracle [N]CLOB\n" - "Size: %1B\n").arg(data.get_length()); + "Size: %1B\n").arg(getLength()); } + + /* virtual */ QString tooltipData() const + { + return QString("Datape: Oracle [N]CLOB\n" "Size: %1B\n").arg(getLength()); + } + /* virtual */ QString dataTypeName() const { - return QString("clob"); + return QString("CLOB"); } /* virtual */ QByteArray read() const { @@ -200,6 +231,14 @@ mutable trotl::SqlClob data; protected: + ub4 getLength() const + { + if(!_length) + _length = data.get_length(); + return _length; + }; + + mutable ub4 _length; // NOTE: OCILobGetLength makes one roundtrip to the server toOracleClob(toOracleClob const&); toOracleClob operator=(toOracleClob const&); //TODO copying prohibited @@ -221,11 +260,31 @@ { return true; } - /* virtual */ QString summary() const + + /* virtual */ QString displayData() const { return QString("Datape: Oracle BLOB\n" "Size: %1B\n").arg(data.get_length()); } + + /* virtual */ QString editData() const + { + return QString("Datape: Oracle BLOB\n" + "Size: %1B\n").arg(data.get_length()); + } + + /* virtual */ QString userData() const + { + return QString("Datape: Oracle BLOB\n" + "Size: %1B\n").arg(data.get_length()); + } + + /* virtual */ QString tooltipData() const + { + return QString("Datape: Oracle BLOB\n" + "Size: %1B\n").arg(data.get_length()); + } + /* virtual */ QString dataTypeName() const { return QString("blob"); @@ -272,12 +331,28 @@ { return false; } - /* virtual */ QString summary() const + + + /* virtual */ QString displayData() const { - return QString("Datape: user type collection %1\n\%2") - .arg(data._data_type_name.c_str()) - .arg(((::trotl::tstring)data).c_str()); + return QString("collection"); } + + /* virtual */ QString editData() const + { + return QString("collection"); + } + + /* virtual */ QString userData() const + { + return QString("collection"); + } + + /* virtual */ QString tooltipData() const + { + return QString("collection"); + } + /* virtual */ QString dataTypeName() const { return QString(data._data_type_name.c_str()); @@ -1018,7 +1093,7 @@ virtual void initialize(void) { - //toMaxLong = toConfigurationSingle::Instance().maxLong(); + toMaxLong = toConfigurationSingle::Instance().maxLong(); ::trotl::g_OCIPL_MAX_LONG = ( toConfigurationSingle::Instance().maxLong() == -1 ? ::trotl::g_OCIPL_MAX_LONG : toConfigurationSingle::Instance().maxLong() ); ::trotl::OciEnvAlloc *_envallocp = new ::trotl::OciEnvAlloc; @@ -1585,13 +1660,13 @@ */ if (Unlimited->isChecked()) { - //toMaxLong = -1; toConfigurationSingle::Instance().setMaxLong(-1); + toMaxLong = 30000; } else { toConfigurationSingle::Instance().setMaxLong(MaxLong->text().toInt()); - //toMaxLong = MaxLong->text().toInt(); + toMaxLong = MaxLong->text().toInt(); } } Modified: branches/tora-trotl/src/toqvalue.h =================================================================== --- branches/tora-trotl/src/toqvalue.h 2010-10-05 11:36:30 UTC (rev 3730) +++ branches/tora-trotl/src/toqvalue.h 2010-10-05 12:07:59 UTC (rev 3731) @@ -72,8 +72,14 @@ public: virtual bool isBinary() const = 0; virtual bool isLarge() const = 0; - virtual QString summary() const = 0; + + virtual QString displayData() const = 0; + virtual QString editData() const = 0; + virtual QString userData() const = 0; + virtual QString tooltipData() const = 0; + virtual QString dataTypeName() const = 0; + virtual QByteArray read() const = 0; virtual void write(QByteArray const &) = 0; virtual ~complexType() {}; Modified: branches/tora-trotl/src/toresultmodel.cpp =================================================================== --- branches/tora-trotl/src/toresultmodel.cpp 2010-10-05 11:36:30 UTC (rev 3730) +++ branches/tora-trotl/src/toresultmodel.cpp 2010-10-05 12:07:59 UTC (rev 3731) @@ -498,15 +498,23 @@ switch(role) { + case Qt::ToolTipRole: case Qt::EditRole: - case Qt::ToolTipRole: + if (data.isNull()) + return toNull(data).toQVariant(); + if (data.isUserType()) + { + toQValue::complexType *i = data.toQVariant().value<toQValue::complexType*>(); + return QVariant(i->editData()); + } + return data.toQVariant(); case Qt::DisplayRole: if (data.isNull()) return toNull(data).toQVariant(); if (data.isUserType()) { toQValue::complexType *i = data.toQVariant().value<toQValue::complexType*>(); - return QVariant(QString("{%1}").arg(i->dataTypeName())); + return QVariant(i->displayData()); } return data.toQVariant(); case Qt::BackgroundRole: Modified: branches/tora-trotl/src/trotl/src/trotl_exc.cpp =================================================================== --- branches/tora-trotl/src/trotl/src/trotl_exc.cpp 2010-10-05 11:36:30 UTC (rev 3730) +++ branches/tora-trotl/src/trotl/src/trotl_exc.cpp 2010-10-05 12:07:59 UTC (rev 3731) @@ -115,8 +115,7 @@ _parse_offset = 0; } -//OciException::OciException(tstring where, OCIError* errh, SqlStatement& stmt) - OciException::OciException(tstring where, SqlStatement& stmt) : +OciException::OciException(tstring where, SqlStatement& stmt) : _where(where), _mess(where) { #ifdef DEBUG @@ -171,7 +170,7 @@ const char* sql = _last_sql.c_str(); size_t l = strlen(buffer); - int line = 1; + unsigned line = 1; const char* s = sql; const char* e = sql + _parse_offset; const char* lp = sql; @@ -191,7 +190,7 @@ //#ifdef __STDC_WANT_SECURE_LIB__ // char* b = buffer+l + snprintf_s(buffer+l, sizeof(buffer)-l, _TRUNCATE, "\nerror at SQL position %d [%d.%d]:\n", _parse_offset, line, column); //#else - char* b = buffer+l + snprintf(buffer+l, sizeof(buffer)-l-1, "\nerror at SQL position %d [%d.%d]:\n", _parse_offset, line, column); + char* b = buffer+l + snprintf(buffer+l, sizeof(buffer)-l-1, "\nerror at SQL position %u [%u.%zu]:\n", (unsigned)_parse_offset, line, column); //#endif char* p = b; s = lp; @@ -226,26 +225,27 @@ } OciException::OciException(tstring where, const char* msg) : - _where(where), _mess(where), _parse_offset(0), _last_sql("") + _where(where), _mess(where), _last_sql(""), _parse_offset(0) { #ifdef DEBUG dbg::stack s; std::copy(s.begin(), s.end(), std::ostream_iterator<dbg::stack_frame>(_stack, "\n")); - _mess += "\n" + _stack.str() + msg; -#endif + _mess += "\n" + _stack.str(); +#endif + _mess += msg; } -OciException::OciException(const OciException& other): - _sql_error_code(other._sql_error_code), - _where(other._where), - _mess(other._mess), - _stack(), - _last_sql(other._last_sql), - _parse_offset(other._parse_offset) - { - //throw std::logic_error("OciException should not be copied"); - //std::cerr << __TROTL_HERE__ << "OciException should not be copied" << std::endl; - } +OciException::OciException(const OciException& other) + : _sql_error_code(other._sql_error_code) + , _where() //_where(other._where) + , _stack() + , _mess(other._mess) + , _last_sql(other._last_sql) + , _parse_offset() // _parse_offset(other._parse_offset) +{ + //throw std::logic_error("OciException should not be copied"); + //std::cerr << __TROTL_HERE__ << "OciException should not be copied" << std::endl; +} OciException& OciException::arg(int d) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |