code format
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "cdutils_c.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
@@ -6,8 +7,7 @@ using namespace CDUtils;
|
||||
CInterface C;
|
||||
|
||||
|
||||
CInterface::CInterface(): Interface(CDType::cdC) {
|
||||
}
|
||||
CInterface::CInterface(): Interface(CDType::cdC) {}
|
||||
|
||||
|
||||
void CInterface::sendCommand(const CDType & c) {
|
||||
|
||||
@@ -20,26 +20,25 @@
|
||||
#ifndef CDUTILS_C_H
|
||||
#define CDUTILS_C_H
|
||||
|
||||
#include "cdutils_interface.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_interface.h"
|
||||
|
||||
|
||||
namespace CDUtils {
|
||||
|
||||
|
||||
class CD_CORE_EXPORT CInterface: public Interface
|
||||
{
|
||||
class CD_CORE_EXPORT CInterface: public Interface {
|
||||
PIOBJECT_SUBCLASS(CInterface, Interface);
|
||||
|
||||
public:
|
||||
CInterface();
|
||||
|
||||
void sendCommand(const CDType & c);
|
||||
void connect(const CDType & c, PIObject * o, Handler eh);
|
||||
void autoConnect(PIObject * o, const PIString & prefix = PIStringAscii("c_"));
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
extern CD_CORE_EXPORT CDUtils::CInterface C;
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "cdutils_core.h"
|
||||
|
||||
#include "cdutils_parser.h"
|
||||
#include "piconfig.h"
|
||||
#include "pifile.h"
|
||||
#include "piiobytearray.h"
|
||||
#include "piiostring.h"
|
||||
#include "pifile.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
const char CDCore::app_config[] =
|
||||
"include = cd_ip.conf\n\
|
||||
const char CDCore::app_config[] = "include = cd_ip.conf\n\
|
||||
port_rec = 2\n\
|
||||
port_send = 1\n\
|
||||
[connection]\n\
|
||||
@@ -17,8 +17,7 @@ const char CDCore::app_config[] =
|
||||
connectionmodel = AAAM2Xja7VXLTttAFD12QpsikKjUSixYlLbKEpIUtVIlVEfqhk2FWuiGRRolUYtoHgrmpYiv6IItf8AveMMH9E/YsG6Ph3sde5hGoQoblLGuPHfunTPjc49nADxDA110+LTYC7FrPCAPeAO+vZu+aX7c/8PGd45WCJC0OGcfT6FDnmfSTPtwhZFt3HjgDs/Qtu5jPbZHtI/x50XfIzMQbdwEolbg9INP4ku++myPaUtCHYRaT2j1ldIh3VP60/Qff8vSfXLu9BP6JX9K/0TVH6jqVe22P1X/fao/oddWu/paDs1vBf9Jv/EZ91clbyHqv7BL6sscDOd4v4WTqs6jzaHGJ8QJerxlpJSpdZ7IWFJvDW7I2JxZqIM62k6A57RZmMQGmlyrxdV+WGBnmR01mXPI267hBKwp4FeBeo9VPtssxyb7rzHg1B7T9nCMU45U8BZlWuVWtIcD/CRGOqtsbW09851tXsHN0UTlLIAdASjSXnLyLn+H7L2+xbGYvC63Ezqg543egkLmn8qnRF6USbM4Qp9godkhzI777Ne5bCIt/5UtGz2o/yGby0nKpjqmbOa1ynkjmyzIrzvIZUeBPjvlUmbh32EFJbGyJZhR8YcvlS+3TpjhqeWSyvUkpbI9plSWtcKLcsK05beOJVEnhaEFfHEH+RwpeMcpn1JKGqWMNOL+G6wZyahlpdVOtufKfbDS+guLke9O\n\
|
||||
";
|
||||
|
||||
const char CDCore::pult_config[] =
|
||||
"include = cd_ip.conf\n\
|
||||
const char CDCore::pult_config[] = "include = cd_ip.conf\n\
|
||||
port_rec = 1\n\
|
||||
port_send = 2\n\
|
||||
[connection]\n\
|
||||
@@ -55,8 +54,6 @@ __Core_Initializer__::~__Core_Initializer__() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CDCore::CDCore() {
|
||||
setName("CDCore");
|
||||
x_timer.setName("__S__.CDCore.x_timer");
|
||||
@@ -110,8 +107,7 @@ void CDCore::cd_write(CDSection * cd, PIIODevice * d) {
|
||||
void CDCore::cd_read(CDSection * cd, PIIODevice * d) {
|
||||
PIConfig conf(d, PIIODevice::ReadOnly);
|
||||
cd->read(&(conf.rootEntry()));
|
||||
if (cd->cd_type_ == CDType::cdX)
|
||||
x_selected = cd->collectX();
|
||||
if (cd->cd_type_ == CDType::cdX) x_selected = cd->collectX();
|
||||
initRoot(cd);
|
||||
raiseChangedGlobal(cd->cd_type_);
|
||||
/*PIVector<PIIODevice * > ds = connection.allDevices();
|
||||
@@ -231,8 +227,7 @@ void CDCore::release() {
|
||||
|
||||
void CDCore::startX(double freq) {
|
||||
// piCout << "start x" << x_timer.isRunning() << freq;
|
||||
if (!x_timer.isRunning())
|
||||
x_timer.start(1000. / piMaxd(freq, 0.01));
|
||||
if (!x_timer.isRunning()) x_timer.start(1000. / piMaxd(freq, 0.01));
|
||||
}
|
||||
|
||||
|
||||
@@ -325,29 +320,37 @@ void CDCore::sendThread() {
|
||||
bool ok = datatr.send(send_data);
|
||||
switch (h.type) {
|
||||
case CD_KSend:
|
||||
if (ok) K_Sended();
|
||||
else K_SendFail();
|
||||
if (ok)
|
||||
K_Sended();
|
||||
else
|
||||
K_SendFail();
|
||||
break;
|
||||
case CD_KQuery:
|
||||
if (!ok) K_ReceiveFail();
|
||||
break;
|
||||
case CD_XSend:
|
||||
if (ok) X_Sended();
|
||||
else X_SendFail();
|
||||
if (ok)
|
||||
X_Sended();
|
||||
else
|
||||
X_SendFail();
|
||||
break;
|
||||
case CD_XQuery:
|
||||
if (!ok) X_ReceiveFail();
|
||||
break;
|
||||
case CD_CSend:
|
||||
if (ok) C_Sended();
|
||||
else C_SendFail();
|
||||
if (ok)
|
||||
C_Sended();
|
||||
else
|
||||
C_SendFail();
|
||||
break;
|
||||
case CD_CQuery:
|
||||
if (!ok) C_ReceiveFail();
|
||||
break;
|
||||
case CD_MSend:
|
||||
if (ok) M_Sended();
|
||||
else M_SendFail();
|
||||
if (ok)
|
||||
M_Sended();
|
||||
else
|
||||
M_SendFail();
|
||||
break;
|
||||
case CD_MQuery:
|
||||
if (!ok) M_ReceiveFail();
|
||||
@@ -404,7 +407,8 @@ PIByteArray CDCore::makeHeader(CDPacketType type, int session_id) const {
|
||||
PacketHeader h;
|
||||
h.type = type;
|
||||
h.session_id = session_id;
|
||||
PIByteArray ret; ret << h;
|
||||
PIByteArray ret;
|
||||
ret << h;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -432,9 +436,7 @@ void CDCore::procReceivedPacket(PIByteArray & ba) {
|
||||
case CD_Ping:
|
||||
// piCoutObj << "ping";
|
||||
break;
|
||||
case CD_KQuery:
|
||||
send(CDType::cdK);
|
||||
break;
|
||||
case CD_KQuery: send(CDType::cdK); break;
|
||||
case CD_KSend: {
|
||||
PIByteArray k;
|
||||
ba >> k;
|
||||
@@ -450,9 +452,7 @@ void CDCore::procReceivedPacket(PIByteArray & ba) {
|
||||
ba >> p;
|
||||
k_[p.path].setValue(p.value);
|
||||
} break;
|
||||
case CD_XQuery:
|
||||
send(CDType::cdX);
|
||||
break;
|
||||
case CD_XQuery: send(CDType::cdX); break;
|
||||
case CD_XSend: {
|
||||
PIByteArray x;
|
||||
ba >> x;
|
||||
@@ -488,9 +488,7 @@ void CDCore::procReceivedPacket(PIByteArray & ba) {
|
||||
x_mutex.unlock();
|
||||
X_ReceivedX(x_vals);
|
||||
} break;
|
||||
case CD_CQuery:
|
||||
send(CDType::cdC);
|
||||
break;
|
||||
case CD_CQuery: send(CDType::cdC); break;
|
||||
case CD_CSend: {
|
||||
piCoutObj << "C received";
|
||||
PIByteArray c;
|
||||
@@ -511,9 +509,7 @@ void CDCore::procReceivedPacket(PIByteArray & ba) {
|
||||
// piCoutObj << "found" << sp << h.first;
|
||||
if (h.first && h.second) h.second(h.first);
|
||||
} break;
|
||||
case CD_MQuery:
|
||||
send(CDType::cdM);
|
||||
break;
|
||||
case CD_MQuery: send(CDType::cdM); break;
|
||||
case CD_MSend: {
|
||||
piCoutObj << "M received";
|
||||
PIByteArray c;
|
||||
@@ -601,4 +597,3 @@ void CDCore::dtReceiveFinished(bool ok) {
|
||||
PIByteArray ba = datatr.data();
|
||||
procReceivedPacket(ba);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
#ifndef CDUTILS_CORE_H
|
||||
#define CDUTILS_CORE_H
|
||||
|
||||
#include "cdutils_types.h"
|
||||
#include "cd_core_export.h"
|
||||
#include "cdutils_protocol.h"
|
||||
#include "cdutils_types.h"
|
||||
#include "piconnection.h"
|
||||
#include "pidatatransfer.h"
|
||||
#include "cd_core_export.h"
|
||||
|
||||
|
||||
namespace CDUtils {
|
||||
@@ -42,13 +42,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class CD_CORE_EXPORT CDCore: public PIObject
|
||||
{
|
||||
class CD_CORE_EXPORT CDCore: public PIObject {
|
||||
PIOBJECT(CDUtils::CDCore);
|
||||
friend class __Core_Initializer__;
|
||||
friend class CDSection;
|
||||
friend class Interface;
|
||||
friend class XInterface;
|
||||
|
||||
public:
|
||||
static CDCore * instance();
|
||||
static bool destroy();
|
||||
@@ -137,12 +137,11 @@ private:
|
||||
PIVector<PIDeque<int>> x_selected;
|
||||
PIMap<PIString, OHPair> c_handlers;
|
||||
bool need_rebuild_x, x_pult_side;
|
||||
|
||||
};
|
||||
|
||||
|
||||
static __Core_Initializer__ __Core_initializer__;
|
||||
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
#endif // CDUTILS_CORE_H
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cdutils_interface.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "piconfig.h"
|
||||
#include "pifile.h"
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#ifndef CDUTILS_INTERFACE_H
|
||||
#define CDUTILS_INTERFACE_H
|
||||
|
||||
#include "cd_core_export.h"
|
||||
#include "cdutils_types.h"
|
||||
#include "piobject.h"
|
||||
#include "cd_core_export.h"
|
||||
|
||||
|
||||
namespace CDUtils {
|
||||
@@ -30,9 +30,9 @@ namespace CDUtils {
|
||||
class CDCore;
|
||||
|
||||
|
||||
class CD_CORE_EXPORT Interface: public PIObject
|
||||
{
|
||||
class CD_CORE_EXPORT Interface: public PIObject {
|
||||
PIOBJECT(CDUtils::Interface);
|
||||
|
||||
public:
|
||||
Interface(CDType::cdT type_);
|
||||
|
||||
@@ -86,11 +86,10 @@ protected:
|
||||
CDType::cdT type;
|
||||
PIString file_;
|
||||
int file_size;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
|
||||
#endif // CDUTILS_INTERFACE_H
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cdutils_k.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
@@ -6,8 +7,7 @@ using namespace CDUtils;
|
||||
KInterface K;
|
||||
|
||||
|
||||
KInterface::KInterface(): Interface(CDType::cdK) {
|
||||
}
|
||||
KInterface::KInterface(): Interface(CDType::cdK) {}
|
||||
|
||||
|
||||
void KInterface::directChange(const CDType & k) {
|
||||
|
||||
@@ -20,16 +20,16 @@
|
||||
#ifndef CDUTILS_K_H
|
||||
#define CDUTILS_K_H
|
||||
|
||||
#include "cdutils_interface.h"
|
||||
#include "cd_core_export.h"
|
||||
#include "cdutils_interface.h"
|
||||
|
||||
|
||||
namespace CDUtils {
|
||||
|
||||
|
||||
class CD_CORE_EXPORT KInterface: public Interface
|
||||
{
|
||||
class CD_CORE_EXPORT KInterface: public Interface {
|
||||
PIOBJECT_SUBCLASS(KInterface, Interface);
|
||||
|
||||
public:
|
||||
KInterface();
|
||||
|
||||
@@ -37,10 +37,9 @@ public:
|
||||
|
||||
void directChange(const CDType & k);
|
||||
void directChange(const CDType & k, double v);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
extern CD_CORE_EXPORT CDUtils::KInterface K;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cdutils_m.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
@@ -20,16 +20,16 @@
|
||||
#ifndef CDUTILS_M_H
|
||||
#define CDUTILS_M_H
|
||||
|
||||
#include "cdutils_interface.h"
|
||||
#include "cd_core_export.h"
|
||||
#include "cdutils_interface.h"
|
||||
|
||||
|
||||
namespace CDUtils {
|
||||
|
||||
|
||||
class CD_CORE_EXPORT MInterface: public Interface
|
||||
{
|
||||
class CD_CORE_EXPORT MInterface: public Interface {
|
||||
PIOBJECT_SUBCLASS(MInterface, Interface);
|
||||
|
||||
public:
|
||||
MInterface();
|
||||
|
||||
@@ -46,10 +46,9 @@ public:
|
||||
|
||||
private:
|
||||
PICout createPICout(const CDType & m) const;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
extern CD_CORE_EXPORT CDUtils::MInterface M;
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "cdutils_parser.h"
|
||||
|
||||
#include "cdutils_types.h"
|
||||
#include "piiostring.h"
|
||||
#include "piiobytearray.h"
|
||||
#include "pifile.h"
|
||||
#include "piiobytearray.h"
|
||||
#include "piiostring.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
@@ -34,6 +34,6 @@ CD_CORE_EXPORT CDSection parse(PIIODevice * d, int cdsection_type);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
#endif // CDUTILS_PARSER_H
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#ifndef CDUTILS_PROTOCOL_H
|
||||
#define CDUTILS_PROTOCOL_H
|
||||
|
||||
#include "pistring.h"
|
||||
#include "cd_core_export.h"
|
||||
#include "pistring.h"
|
||||
|
||||
namespace CDUtils {
|
||||
|
||||
@@ -62,13 +62,25 @@ namespace CDUtils {
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef PIP_BINARY_STREAM
|
||||
BINARY_STREAM_WRITE(PacketKDirectChange) {s << v.path << v.value; return s;}
|
||||
BINARY_STREAM_READ (PacketKDirectChange) {s >> v.path >> v.value; return s;}
|
||||
BINARY_STREAM_WRITE(PacketKDirectChange) {
|
||||
s << v.path << v.value;
|
||||
return s;
|
||||
}
|
||||
BINARY_STREAM_READ(PacketKDirectChange) {
|
||||
s >> v.path >> v.value;
|
||||
return s;
|
||||
}
|
||||
#else
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PacketKDirectChange & v) {s << v.path << v.value; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PacketKDirectChange & v) {s >> v.path >> v.value; return s;}
|
||||
inline PIByteArray & operator<<(PIByteArray & s, const PacketKDirectChange & v) {
|
||||
s << v.path << v.value;
|
||||
return s;
|
||||
}
|
||||
inline PIByteArray & operator>>(PIByteArray & s, PacketKDirectChange & v) {
|
||||
s >> v.path >> v.value;
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
#endif // CDUTILS_PROTOCOL_H
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "cdutils_types.h"
|
||||
#include "piconfig.h"
|
||||
#include "pifile.h"
|
||||
#include "pievaluator.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "piconfig.h"
|
||||
#include "pievaluator.h"
|
||||
#include "pifile.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
@@ -21,8 +22,6 @@ CDType::CDType() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t) {
|
||||
index_ = i;
|
||||
name_ = n.trimmed();
|
||||
@@ -45,7 +44,8 @@ CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v
|
||||
// piCout << type_.size() << type_.toUTF8();
|
||||
// piCout << formula_.size() << formula_.toUTF8();
|
||||
// piCout << comment_.size() << comment_.toUTF8();
|
||||
// piCout << "[CDType] create" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ << ":" << (cd_type_ == cdK);
|
||||
// piCout << "[CDType] create" << name_ << ":" << type_ << ":" << value_s << ":" << value_d << ":" << formula_ << ":" << comment_ <<
|
||||
//":" << (cd_type_ == cdK);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,29 +130,31 @@ PIStringList CDType::pathString() const {
|
||||
if (!ps) return ret;
|
||||
for (int i = 0; i < path_.size_s() - 1; ++i) {
|
||||
ps = &(ps->section(path_[i]));
|
||||
if (!ps->alias.isEmpty()) ret << ps->alias;
|
||||
else ret << PIString::fromNumber(path_[i]);
|
||||
if (!ps->alias.isEmpty())
|
||||
ret << ps->alias;
|
||||
else
|
||||
ret << PIString::fromNumber(path_[i]);
|
||||
}
|
||||
if (!name_.isEmpty()) ret << name_;
|
||||
else ret << PIString::fromNumber(index_);
|
||||
if (!name_.isEmpty())
|
||||
ret << name_;
|
||||
else
|
||||
ret << PIString::fromNumber(index_);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void CDType::readX(PIByteArray & ba) {
|
||||
if (ba.size() < 5) return;
|
||||
uchar t(0); ba >> t;
|
||||
uchar t(0);
|
||||
ba >> t;
|
||||
rmode_ = (XMode)t;
|
||||
switch (rmode_) {
|
||||
case X_Current:
|
||||
ba >> value_d;
|
||||
break;
|
||||
case X_Current: ba >> value_d; break;
|
||||
case X_All_Avg: {
|
||||
PIVector<double> ah;
|
||||
ba >> ah;
|
||||
history << ah;
|
||||
if (!history.isEmpty())
|
||||
value_d = history.back();
|
||||
if (!history.isEmpty()) value_d = history.back();
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
@@ -164,9 +166,7 @@ void CDType::readX(PIByteArray & ba) {
|
||||
void CDType::writeX(PIByteArray & ba) {
|
||||
ba << uchar(mode_);
|
||||
switch (mode_) {
|
||||
case X_Current:
|
||||
ba << value_d;
|
||||
break;
|
||||
case X_Current: ba << value_d; break;
|
||||
case X_All_Avg:
|
||||
ba << history;
|
||||
history.clear();
|
||||
@@ -214,8 +214,7 @@ bool CDType::calculate(PIEvaluator * e, PIVector<const CDType * > stack) {
|
||||
error_ = e->error();
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
if (e->isCorrect())
|
||||
} else if (e->isCorrect())
|
||||
ev = e->evaluate().real();
|
||||
// piCout << value_s << value_i << value_d << ev;
|
||||
// if ((value_d == 0.) || (piAbsd(value_d) < piAbsd(ev))) value_d = ev;
|
||||
@@ -347,8 +346,10 @@ CDType & CDSection::getByName(const PIString & name_) {
|
||||
auto it = cs->s.makeIterator();
|
||||
while (it.next()) {
|
||||
bool f = false;
|
||||
if (isd) f = (dv == it.key());
|
||||
else f = (np[i] == it.value().alias);
|
||||
if (isd)
|
||||
f = (dv == it.key());
|
||||
else
|
||||
f = (np[i] == it.value().alias);
|
||||
// piCout << "s..." << it.key() << it.value().alias << f;
|
||||
if (f) {
|
||||
ns = &(it.value());
|
||||
@@ -367,11 +368,12 @@ CDType & CDSection::getByName(const PIString & name_) {
|
||||
auto it = cs->cd.makeIterator();
|
||||
while (it.next()) {
|
||||
bool f = false;
|
||||
if (isd) f = (dv == it.key());
|
||||
else f = (np.back() == it.value().name());
|
||||
if (isd)
|
||||
f = (dv == it.key());
|
||||
else
|
||||
f = (np.back() == it.value().name());
|
||||
// piCout << "k..." << it.key() << it.value().name() << f;
|
||||
if (f)
|
||||
return cs->cd[it.key()];
|
||||
if (f) return cs->cd[it.key()];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -393,9 +395,15 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
|
||||
// piCout << "[CDSection] write start";
|
||||
PIString l;
|
||||
PIStringList cdtl;
|
||||
cdtl << "null" << "k" << "x" << "c" << "m";
|
||||
if (prefix.isEmpty()) l = "[" + cdtl[cd_type_] + "]";
|
||||
else l = "[" + prefix + "." + cdtl[cd_type_] + "]";
|
||||
cdtl << "null"
|
||||
<< "k"
|
||||
<< "x"
|
||||
<< "c"
|
||||
<< "m";
|
||||
if (prefix.isEmpty())
|
||||
l = "[" + cdtl[cd_type_] + "]";
|
||||
else
|
||||
l = "[" + prefix + "." + cdtl[cd_type_] + "]";
|
||||
l += "\n";
|
||||
d->write(l.toUTF8());
|
||||
l = "name = " + name + " \n";
|
||||
@@ -426,7 +434,8 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
|
||||
case CDType::cdX:
|
||||
l = PIString::fromNumber(ck.index()) + ".name = " + ck.name() + " #s " + ck.comment() + " \n";
|
||||
d->write(l.toUTF8());
|
||||
l = PIString::fromNumber(ck.index()) + ".mode = " + PIString::fromNumber((int)ck.xmode()) + " #e (0 - cur, 1 - all_avg) " + "\n";
|
||||
l = PIString::fromNumber(ck.index()) + ".mode = " + PIString::fromNumber((int)ck.xmode()) + " #e (0 - cur, 1 - all_avg) " +
|
||||
"\n";
|
||||
d->write(l.toUTF8());
|
||||
l = PIString::fromNumber(ck.index()) + ".avg = " + PIString::fromNumber(ck.avg()) + " #n " + "\n";
|
||||
d->write(l.toUTF8());
|
||||
@@ -441,8 +450,10 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
|
||||
}
|
||||
}
|
||||
if (!s.isEmpty()) {
|
||||
if (prefix.isEmpty()) l = "s";
|
||||
else l = prefix + ".s";
|
||||
if (prefix.isEmpty())
|
||||
l = "s";
|
||||
else
|
||||
l = prefix + ".s";
|
||||
auto j = s.makeIterator();
|
||||
while (j.next()) {
|
||||
j.value().write(d, l + "." + PIString::fromNumber(j.key()));
|
||||
@@ -459,7 +470,11 @@ void CDSection::write(PIIODevice * d, const PIString & prefix) {
|
||||
void CDSection::read(const void * ep) {
|
||||
// piCout << "[CDSection] read start";
|
||||
PIStringList cdtl;
|
||||
cdtl << "null" << "k" << "x" << "c" << "m";
|
||||
cdtl << "null"
|
||||
<< "k"
|
||||
<< "x"
|
||||
<< "c"
|
||||
<< "m";
|
||||
cd.clear();
|
||||
s.clear();
|
||||
PIConfig::Entry & e(*(PIConfig::Entry *)ep);
|
||||
@@ -477,10 +492,15 @@ void CDSection::read(const void * ep) {
|
||||
switch (cd_type_) {
|
||||
case CDType::cdNull: break;
|
||||
case CDType::cdK:
|
||||
c = CDType(id, e->getValue("v").comment(), e->getValue("v").type(), e->getValue("v").value(), e->getValue("f").value(), e->getValue("f").comment(), cd_type_);
|
||||
c = CDType(id,
|
||||
e->getValue("v").comment(),
|
||||
e->getValue("v").type(),
|
||||
e->getValue("v").value(),
|
||||
e->getValue("f").value(),
|
||||
e->getValue("f").comment(),
|
||||
cd_type_);
|
||||
ev = e->getValue("ev", "").value();
|
||||
if (!ev.isEmpty())
|
||||
c.enum_values = c.parseEnumComment(ev);
|
||||
if (!ev.isEmpty()) c.enum_values = c.parseEnumComment(ev);
|
||||
break;
|
||||
case CDType::cdX:
|
||||
c = CDType(id, e->getValue("name").value(), PIString(), PIString(), PIString(), e->getValue("name").comment(), cd_type_);
|
||||
@@ -672,5 +692,3 @@ PIVariantTypes::Enum CDSection::enumValues() const {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
#ifndef CDUTILS_TYPES_H
|
||||
#define CDUTILS_TYPES_H
|
||||
|
||||
#include "pistring.h"
|
||||
#include "pimap.h"
|
||||
#include "pivariant.h"
|
||||
#include "cd_core_export.h"
|
||||
#include "pimap.h"
|
||||
#include "pistring.h"
|
||||
#include "pivariant.h"
|
||||
|
||||
class PIIODevice;
|
||||
class PIEvaluator;
|
||||
@@ -53,9 +53,19 @@ class CD_CORE_EXPORT CDType {
|
||||
friend class CDCore;
|
||||
friend class Interface;
|
||||
friend class XInterface;
|
||||
|
||||
public:
|
||||
enum cdT {cdNull, cdK, cdX, cdC, cdM};
|
||||
enum XMode {X_Current, X_All_Avg};
|
||||
enum cdT {
|
||||
cdNull,
|
||||
cdK,
|
||||
cdX,
|
||||
cdC,
|
||||
cdM
|
||||
};
|
||||
enum XMode {
|
||||
X_Current,
|
||||
X_All_Avg
|
||||
};
|
||||
|
||||
CDType();
|
||||
CDType(int i, const PIString & n, const PIString & t, const PIString & v, const PIString & f, const PIString & c, cdT cd_t);
|
||||
@@ -120,8 +130,8 @@ class CD_CORE_EXPORT CDSection {
|
||||
friend class ::CD_Pult;
|
||||
friend class ::CDItem;
|
||||
friend class ::CDItemModel;
|
||||
public:
|
||||
|
||||
public:
|
||||
CDSection(CDType::cdT type_ = CDType::cdNull);
|
||||
|
||||
bool test(int v) { return cd.value(v).toBool(); }
|
||||
@@ -168,7 +178,7 @@ protected:
|
||||
CDType::cdT cd_type_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
|
||||
inline PICout operator<<(PICout s, const CDUtils::CDType & v) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cdutils_x.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
@@ -20,16 +20,16 @@
|
||||
#ifndef CDUTILS_X_H
|
||||
#define CDUTILS_X_H
|
||||
|
||||
#include "cdutils_interface.h"
|
||||
#include "cd_core_export.h"
|
||||
#include "cdutils_interface.h"
|
||||
|
||||
|
||||
namespace CDUtils {
|
||||
|
||||
|
||||
class CD_CORE_EXPORT XInterface: public Interface
|
||||
{
|
||||
class CD_CORE_EXPORT XInterface: public Interface {
|
||||
PIOBJECT_SUBCLASS(XInterface, Interface);
|
||||
|
||||
public:
|
||||
XInterface();
|
||||
|
||||
@@ -47,10 +47,9 @@ public:
|
||||
|
||||
void start(double freq = 20.);
|
||||
void stop();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
extern CD_CORE_EXPORT CDUtils::XInterface X;
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdtest.h"
|
||||
#include "pip.h"
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "k_description.h"
|
||||
#include "pip.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
class Core : public PIObject
|
||||
{
|
||||
class Core: public PIObject {
|
||||
PIOBJECT(Core);
|
||||
|
||||
public:
|
||||
Core() {
|
||||
CDCore::instance()->initApp();
|
||||
@@ -94,4 +94,3 @@ int main(int argc, char *argv[]) {
|
||||
piCout << "DELETED";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
#include "qcd_core.h"
|
||||
#include "cdutils_k.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "piqt.h"
|
||||
#include <QWidget>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGroupBox>
|
||||
#include <QSpinBox>
|
||||
#include <QSlider>
|
||||
#include <QScrollBar>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QGroupBox>
|
||||
#include <QLineEdit>
|
||||
#include <spinslider.h>
|
||||
#include <QScrollBar>
|
||||
#include <QSlider>
|
||||
#include <QSpinBox>
|
||||
#include <QWidget>
|
||||
#include <clineedit.h>
|
||||
#include <evalspinbox.h>
|
||||
#include <qvariantedit.h>
|
||||
#include <qcd_view.h>
|
||||
#include <qvariantedit.h>
|
||||
#include <spinslider.h>
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
@@ -40,8 +42,6 @@ __QCore_Initializer__::~__QCore_Initializer__() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QCDCore::QCDCore() {
|
||||
setObjectName("QCDCore");
|
||||
setName("QCDCore");
|
||||
@@ -50,8 +50,7 @@ QCDCore::QCDCore() {
|
||||
}
|
||||
|
||||
|
||||
QCDCore::~QCDCore() {
|
||||
}
|
||||
QCDCore::~QCDCore() {}
|
||||
|
||||
|
||||
void QCDCore::K_ChangedGlobal() {
|
||||
@@ -256,16 +255,12 @@ bool QCDCore::unbindWidget(QWidget * w) {
|
||||
// qDebug() << "unbind" << w;
|
||||
if (!binded_widgets.contains(w)) return false;
|
||||
QString cn = w->metaObject()->className();
|
||||
if (cn == "QCheckBox" || cn == "QGroupBox")
|
||||
disconnect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool)));
|
||||
if (cn == "QSpinBox" || cn == "QSlider" || cn == "QScrollBar")
|
||||
disconnect(w, SIGNAL(valueChanged(int)), this, SLOT(slotInt(int)));
|
||||
if (cn == "QCheckBox" || cn == "QGroupBox") disconnect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool)));
|
||||
if (cn == "QSpinBox" || cn == "QSlider" || cn == "QScrollBar") disconnect(w, SIGNAL(valueChanged(int)), this, SLOT(slotInt(int)));
|
||||
if (cn == "QDoubleSpinBox" || cn == "SpinSlider" || cn == "EvalSpinBox")
|
||||
disconnect(w, SIGNAL(valueChanged(double)), this, SLOT(slotDouble(double)));
|
||||
if (cn == "QLineEdit" || cn == "CLineEdit")
|
||||
disconnect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)));
|
||||
if (cn == "QVariantEdit")
|
||||
disconnect(w, SIGNAL(valueChanged(QVariant)), this, SLOT(slotVariant(QVariant)));
|
||||
if (cn == "QLineEdit" || cn == "CLineEdit") disconnect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)));
|
||||
if (cn == "QVariantEdit") disconnect(w, SIGNAL(valueChanged(QVariant)), this, SLOT(slotVariant(QVariant)));
|
||||
// qDebug() << "remove b" << binded_widgets.size();
|
||||
binded_widgets.remove(w);
|
||||
// qDebug() << "remove a" << binded_widgets.size();
|
||||
|
||||
@@ -20,12 +20,13 @@
|
||||
#ifndef QCD_CORE_H
|
||||
#define QCD_CORE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMultiMap>
|
||||
#include <QVariant>
|
||||
#include "piobject.h"
|
||||
#include "cdutils_types.h"
|
||||
#include "cd_qt_export.h"
|
||||
#include "cdutils_types.h"
|
||||
#include "piobject.h"
|
||||
|
||||
#include <QMultiMap>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
class QCDCore;
|
||||
@@ -40,11 +41,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class CD_QT_EXPORT QCDCore: public QObject, public PIObject
|
||||
{
|
||||
class CD_QT_EXPORT QCDCore
|
||||
: public QObject
|
||||
, public PIObject {
|
||||
Q_OBJECT
|
||||
PIOBJECT(QCDCore);
|
||||
friend class __QCore_Initializer__;
|
||||
|
||||
public:
|
||||
static QCDCore * instance() { return __QCore_Initializer__::__instance__; }
|
||||
|
||||
@@ -87,7 +90,6 @@ public slots:
|
||||
|
||||
signals:
|
||||
void updateViewRequest();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "qcd_graphic.h"
|
||||
#include "ui_qcd_graphic.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "graphic.h"
|
||||
#include "piqt.h"
|
||||
#include "ui_qcd_graphic.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
@@ -20,15 +20,16 @@
|
||||
#ifndef QCD_GRAPHIC_H
|
||||
#define QCD_GRAPHIC_H
|
||||
|
||||
#include "cd_qt_export.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <evalspinbox.h>
|
||||
#include <pistring.h>
|
||||
#include "cd_qt_export.h"
|
||||
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
namespace Ui {
|
||||
class CDGraphicWidget;
|
||||
@@ -42,6 +43,7 @@ class CD_QT_EXPORT CDGraphicWidget: public QWidget {
|
||||
Q_OBJECT
|
||||
friend class CDGraphics;
|
||||
friend class GDockWidget;
|
||||
|
||||
public:
|
||||
CDGraphicWidget(QWidget * p = 0);
|
||||
|
||||
@@ -60,7 +62,6 @@ private:
|
||||
private slots:
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "qcd_modedialog.h"
|
||||
|
||||
#include "ui_qcd_modedialog.h"
|
||||
|
||||
|
||||
@@ -25,11 +26,8 @@ CDUtils::UpdateModeFlags QCDModeDialog::mode() const {
|
||||
void QCDModeDialog::changeEvent(QEvent * e) {
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case QEvent::LanguageChange: ui->retranslateUi(this); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,18 @@
|
||||
#ifndef QCD_MODEDIALOG_H
|
||||
#define QCD_MODEDIALOG_H
|
||||
|
||||
#include "cd_qt_export.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <cdutils_types.h>
|
||||
#include "cd_qt_export.h"
|
||||
|
||||
namespace Ui {
|
||||
class QCDModeDialog;
|
||||
}
|
||||
|
||||
class CD_QT_EXPORT QCDModeDialog: public QDialog
|
||||
{
|
||||
class CD_QT_EXPORT QCDModeDialog: public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QCDModeDialog(QWidget * parent = 0);
|
||||
~QCDModeDialog();
|
||||
@@ -45,7 +46,6 @@ protected:
|
||||
private slots:
|
||||
void on_checkSaveIndex_clicked(bool checked);
|
||||
void on_checkSaveName_clicked(bool checked);
|
||||
|
||||
};
|
||||
|
||||
#endif // QCD_MODEDIALOG_H
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#include "qcd_model.h"
|
||||
#include "cdutils_interface.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_interface.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "piqt.h"
|
||||
#include <QDebug>
|
||||
#include "qad_types.h"
|
||||
#include "qvariantedit.h"
|
||||
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <QMimeData>
|
||||
#include <QPainter>
|
||||
#include "qvariantedit.h"
|
||||
#include "qad_types.h"
|
||||
|
||||
|
||||
using namespace CDUtils;
|
||||
@@ -36,8 +38,10 @@ QVariant CDItem::data(int column, int role) const {
|
||||
switch (type_) {
|
||||
case ItemCDType: {
|
||||
CDType & t(interface->section(buildPath())[index_]);
|
||||
if (t.errorString().isEmpty()) return QBrush(QColor(255, 250, 230));
|
||||
else return QBrush(QColor(255, 128, 128));
|
||||
if (t.errorString().isEmpty())
|
||||
return QBrush(QColor(255, 250, 230));
|
||||
else
|
||||
return QBrush(QColor(255, 128, 128));
|
||||
}
|
||||
case ItemCDSection: return QBrush(QColor(230, 250, 230));
|
||||
}
|
||||
@@ -45,8 +49,10 @@ QVariant CDItem::data(int column, int role) const {
|
||||
if (role == Qt::CheckStateRole && type_ == ItemCDType) {
|
||||
CDType & t(interface->section(buildPath())[index_]);
|
||||
if (column == cValue && t.cd_type() == CDType::cdK) {
|
||||
if (t.type() == "b") return t.toBool() ? Qt::Checked : Qt::Unchecked;
|
||||
else QVariant();
|
||||
if (t.type() == "b")
|
||||
return t.toBool() ? Qt::Checked : Qt::Unchecked;
|
||||
else
|
||||
QVariant();
|
||||
}
|
||||
if (column == cName_Cmd && t.cd_type() == CDType::cdX) {
|
||||
return t.isSelectedX() ? Qt::Checked : Qt::Unchecked;
|
||||
@@ -96,8 +102,10 @@ QVariant CDItem::value(CDType & t, int role) const {
|
||||
if (t.type() == "e") {
|
||||
QAD::Enum et = PI2QADEnum(t.enumValues());
|
||||
et.selectValue(t.toInt());
|
||||
if (role == Qt::EditRole) return QVariant::fromValue<QAD::Enum>(et);
|
||||
else return et.selectedName();
|
||||
if (role == Qt::EditRole)
|
||||
return QVariant::fromValue<QAD::Enum>(et);
|
||||
else
|
||||
return et.selectedName();
|
||||
}
|
||||
return PI2QString(t.value());
|
||||
}
|
||||
@@ -113,15 +121,9 @@ bool CDItem::setData(int column, const QVariant & value) {
|
||||
}
|
||||
if (t.cd_type() == CDType::cdX) {
|
||||
switch (column) {
|
||||
case cName_Cmd:
|
||||
X.setEnabled(t, value.toBool());
|
||||
return true;
|
||||
case cXMode:
|
||||
t.setXMode((CDType::XMode)value.toInt());
|
||||
return true;
|
||||
case cXAvg:
|
||||
t.setAvg(piMax(value.toInt(), 1));
|
||||
return true;
|
||||
case cName_Cmd: X.setEnabled(t, value.toBool()); return true;
|
||||
case cXMode: t.setXMode((CDType::XMode)value.toInt()); return true;
|
||||
case cXAvg: t.setAvg(piMax(value.toInt(), 1)); return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -166,8 +168,7 @@ QString CDItem::stringType(const PIString & t) const {
|
||||
|
||||
QAD::Enum CDItem::xModeEnum(int v) const {
|
||||
QAD::Enum ret;
|
||||
ret << QAD::Enumerator(CDType::X_Current, "Current")
|
||||
<< QAD::Enumerator(CDType::X_All_Avg, "All, Averaging");
|
||||
ret << QAD::Enumerator(CDType::X_Current, "Current") << QAD::Enumerator(CDType::X_All_Avg, "All, Averaging");
|
||||
ret.selectValue(v);
|
||||
return ret;
|
||||
}
|
||||
@@ -175,8 +176,7 @@ QAD::Enum CDItem::xModeEnum(int v) const {
|
||||
|
||||
// CDKDelegate
|
||||
|
||||
CDDelegate::CDDelegate(QObject *parent) : QStyledItemDelegate(parent) {
|
||||
}
|
||||
CDDelegate::CDDelegate(QObject * parent): QStyledItemDelegate(parent) {}
|
||||
|
||||
|
||||
void CDDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
|
||||
@@ -195,8 +195,7 @@ void CDDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option,
|
||||
QPoint cp = v->mapFromGlobal(QCursor::pos());
|
||||
if (bo.rect.contains(cp, true)) {
|
||||
// bo.state |= QStyle::State_MouseOver;
|
||||
if (qApp->mouseButtons().testFlag(Qt::LeftButton))
|
||||
bo.state |= QStyle::State_On;
|
||||
if (qApp->mouseButtons().testFlag(Qt::LeftButton)) bo.state |= QStyle::State_On;
|
||||
}
|
||||
}
|
||||
qApp->style()->drawControl(QStyle::CE_PushButton, &bo, painter);
|
||||
@@ -204,7 +203,6 @@ void CDDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option,
|
||||
}
|
||||
}
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +223,8 @@ void CDDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const
|
||||
if (v.canConvert<QAD::Enum>()) {
|
||||
QAD::Enum et = v.value<QAD::Enum>();
|
||||
model->setData(index, et.selectedValue(), Qt::EditRole);
|
||||
} else model->setData(index, v, Qt::EditRole);
|
||||
} else
|
||||
model->setData(index, v, Qt::EditRole);
|
||||
}
|
||||
|
||||
|
||||
@@ -284,8 +283,10 @@ QModelIndex CDItemModel::index(int row, int column, const QModelIndex &parent) c
|
||||
if (parent.isValid() && parent.column() != cID) return QModelIndex();
|
||||
CDItem * p = getItem(parent);
|
||||
CDItem * c = p->childs.value(row, 0);
|
||||
if (c) return createIndex(row, column, c);
|
||||
else return QModelIndex();
|
||||
if (c)
|
||||
return createIndex(row, column, c);
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
||||
@@ -317,18 +318,13 @@ Qt::ItemFlags CDItemModel::flags(const QModelIndex & index) const {
|
||||
if (item->type_ == CDItem::ItemCDType) {
|
||||
CDType & t(interface->section(item->buildPath())[item->index_]);
|
||||
if (t.cd_type() == CDType::cdK) {
|
||||
if (index.column() == cExpression || index.column() == cValue)
|
||||
f |= Qt::ItemIsEditable;
|
||||
if (index.column() == cValue && t.type() == "b")
|
||||
f |= Qt::ItemIsUserCheckable;
|
||||
if (index.column() == cName_Cmd)
|
||||
f |= Qt::ItemIsDragEnabled;
|
||||
if (index.column() == cExpression || index.column() == cValue) f |= Qt::ItemIsEditable;
|
||||
if (index.column() == cValue && t.type() == "b") f |= Qt::ItemIsUserCheckable;
|
||||
if (index.column() == cName_Cmd) f |= Qt::ItemIsDragEnabled;
|
||||
}
|
||||
if (t.cd_type() == CDType::cdX) {
|
||||
if (index.column() == cXMode || index.column() == cXAvg)
|
||||
f |= Qt::ItemIsEditable;
|
||||
if (index.column() == cName_Cmd)
|
||||
f |= Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled;
|
||||
if (index.column() == cXMode || index.column() == cXAvg) f |= Qt::ItemIsEditable;
|
||||
if (index.column() == cName_Cmd) f |= Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled;
|
||||
}
|
||||
}
|
||||
return f;
|
||||
@@ -376,8 +372,7 @@ QMimeData * CDItemModel::mimeData(const QModelIndexList & indexes) const {
|
||||
if (item) {
|
||||
CDType & t(interface->section(item->buildPath())[item->index_]);
|
||||
QMimeData * mime = new QMimeData();
|
||||
mime->setText(PI2QString(CDCore::instance()->typeLetter(interface->cdType()) +
|
||||
CDCore::pathToString(t.path())));
|
||||
mime->setText(PI2QString(CDCore::instance()->typeLetter(interface->cdType()) + CDCore::pathToString(t.path())));
|
||||
return mime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,12 @@
|
||||
#ifndef QCD_MODEL_H
|
||||
#define QCD_MODEL_H
|
||||
|
||||
#include "cd_qt_export.h"
|
||||
#include "pistring.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QItemDelegate>
|
||||
#include <QStyledItemDelegate>
|
||||
#include "pistring.h"
|
||||
#include "cd_qt_export.h"
|
||||
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
@@ -42,7 +43,7 @@ namespace CDUtils {
|
||||
cComment,
|
||||
cLastColumn,
|
||||
};
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
namespace QAD {
|
||||
struct Enum;
|
||||
@@ -54,8 +55,12 @@ class CDItemModel;
|
||||
class CD_QT_EXPORT CDItem {
|
||||
friend class CDItemModel;
|
||||
friend class CDView;
|
||||
|
||||
public:
|
||||
enum CDItemType{ItemCDType, ItemCDSection};
|
||||
enum CDItemType {
|
||||
ItemCDType,
|
||||
ItemCDSection
|
||||
};
|
||||
CDItem(CDUtils::Interface * interface, int _index, CDItemType type, CDItem * parent);
|
||||
~CDItem();
|
||||
QVariant data(int column, int role) const;
|
||||
@@ -79,9 +84,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class CD_QT_EXPORT CDDelegate : public QStyledItemDelegate
|
||||
{
|
||||
class CD_QT_EXPORT CDDelegate: public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CDDelegate(QObject * parent = 0);
|
||||
|
||||
@@ -91,13 +96,13 @@ public:
|
||||
void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
|
||||
void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CD_QT_EXPORT CDItemModel: public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
friend class CDView;
|
||||
|
||||
public:
|
||||
explicit CDItemModel(int type_, QObject * parent = 0);
|
||||
~CDItemModel();
|
||||
@@ -127,7 +132,6 @@ private:
|
||||
CDItem * root;
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // QCD_MODEL_H
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
#include "qcd_view.h"
|
||||
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "pifile.h"
|
||||
#include "piqt.h"
|
||||
#include "qcd_model.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QMouseEvent>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "qcd_view.h"
|
||||
#include "qcd_model.h"
|
||||
#include "piqt.h"
|
||||
#include "pifile.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
@@ -75,15 +77,13 @@ void CDView::setType(int cdt) {
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CDView::mousePressEvent(QMouseEvent * e) {
|
||||
if (type_ == CDType::cdC) {
|
||||
QModelIndex i = indexAt(e->pos());
|
||||
if (i.isValid() && i.column() == cName_Cmd)
|
||||
update(i);
|
||||
if (i.isValid() && i.column() == cName_Cmd) update(i);
|
||||
}
|
||||
QTreeView::mousePressEvent(e);
|
||||
}
|
||||
@@ -92,8 +92,7 @@ void CDView::mousePressEvent(QMouseEvent * e) {
|
||||
void CDView::mouseReleaseEvent(QMouseEvent * e) {
|
||||
if (type_ == CDType::cdC) {
|
||||
QModelIndex i = indexAt(e->pos());
|
||||
if (i.isValid() && i.column() == cName_Cmd)
|
||||
update(i);
|
||||
if (i.isValid() && i.column() == cName_Cmd) update(i);
|
||||
}
|
||||
QTreeView::mouseReleaseEvent(e);
|
||||
}
|
||||
@@ -101,8 +100,7 @@ void CDView::mouseReleaseEvent(QMouseEvent * e) {
|
||||
|
||||
void CDView::currentChanged(const QModelIndex & cur, const QModelIndex & prev) {
|
||||
if (type_ == CDType::cdC) {
|
||||
if (prev.isValid() && prev.column() == cName_Cmd)
|
||||
update(prev);
|
||||
if (prev.isValid() && prev.column() == cName_Cmd) update(prev);
|
||||
}
|
||||
QTreeView::currentChanged(cur, prev);
|
||||
}
|
||||
@@ -121,8 +119,7 @@ void CDView::refresh() {
|
||||
proxy_->setSourceModel(model_);
|
||||
setModel(proxy_);
|
||||
setItemDelegateForColumn(type_ == CDType::cdC ? cName_Cmd : cValue, new CDDelegate());
|
||||
if (type_ == CDType::cdX)
|
||||
setItemDelegateForColumn(cXMode, new CDDelegate());
|
||||
if (type_ == CDType::cdX) setItemDelegateForColumn(cXMode, new CDDelegate());
|
||||
}
|
||||
model_->rebuildModel();
|
||||
switch ((CDType::cdT)type_) {
|
||||
@@ -130,9 +127,7 @@ void CDView::refresh() {
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
break;
|
||||
case CDType::cdX:
|
||||
setColumnHidden(cExpression, true);
|
||||
break;
|
||||
case CDType::cdX: setColumnHidden(cExpression, true); break;
|
||||
case CDType::cdC:
|
||||
case CDType::cdM:
|
||||
setColumnHidden(cType, true);
|
||||
@@ -144,7 +139,8 @@ void CDView::refresh() {
|
||||
default: break;
|
||||
}
|
||||
expandAll();
|
||||
for (int i = 0; i < model_->columnCount(); i++) resizeColumnToContents(i);
|
||||
for (int i = 0; i < model_->columnCount(); i++)
|
||||
resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +364,9 @@ void CDView::cd_changedGlobal() {
|
||||
|
||||
|
||||
void CDView::pi_cd_messageReceived(PIDeque<int> path, int type, PIString msg) {
|
||||
QMetaObject::invokeMethod(this, "messageReceived", Qt::QueuedConnection,
|
||||
QMetaObject::invokeMethod(this,
|
||||
"messageReceived",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QString, PI2QString(CDCore::pathToString(path))),
|
||||
Q_ARG(int, type),
|
||||
Q_ARG(QString, PI2QString(msg)));
|
||||
|
||||
@@ -20,22 +20,25 @@
|
||||
#ifndef QCD_VIEW_H
|
||||
#define QCD_VIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include "piobject.h"
|
||||
#include "cd_qt_export.h"
|
||||
#include "piobject.h"
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
class CDItemModel;
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
class CD_QT_EXPORT CDView: public QTreeView, public PIObject
|
||||
{
|
||||
class CD_QT_EXPORT CDView
|
||||
: public QTreeView
|
||||
, public PIObject {
|
||||
Q_OBJECT
|
||||
PIOBJECT(CDView);
|
||||
|
||||
public:
|
||||
explicit CDView(QWidget * parent = 0);
|
||||
~CDView();
|
||||
@@ -107,7 +110,6 @@ signals:
|
||||
void _qcd_receiveSucceed(); // PRIVATE
|
||||
void _qcd_receivedX(); // PRIVATE
|
||||
void _qcd_changedGlobal(); // PRIVATE
|
||||
|
||||
};
|
||||
|
||||
#endif // QCD_VIEW_H
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
#include "cddirectk.h"
|
||||
#include "ui_cddirectk_type_dialog.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_model.h"
|
||||
#include "graphic.h"
|
||||
#include "piqt.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_model.h"
|
||||
#include "qvariantedit.h"
|
||||
#include <QFormLayout>
|
||||
#include <QMimeData>
|
||||
#include "ui_cddirectk_type_dialog.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDragMoveEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QMainWindow>
|
||||
#include <QDockWidget>
|
||||
#include <QFormLayout>
|
||||
#include <QInputDialog>
|
||||
#include <QMainWindow>
|
||||
#include <QMimeData>
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
@@ -59,9 +61,7 @@ void KDockWidget::addK(const CDType & t, CDDirectKTypeDialog::TypeInfo ti) {
|
||||
|
||||
QByteArray KDockWidget::save() const {
|
||||
ChunkStream cs;
|
||||
cs.add(1, windowTitle())
|
||||
.add(2, getList(k_list))
|
||||
.add(3, info_list);
|
||||
cs.add(1, windowTitle()).add(2, getList(k_list)).add(3, info_list);
|
||||
return cs.data();
|
||||
}
|
||||
|
||||
@@ -186,21 +186,29 @@ void KDockWidget::removeRow(int r) {
|
||||
if (r < 0 || r >= lay->rowCount()) return;
|
||||
#if QT_VERSION >= 0x050800
|
||||
QFormLayout::TakeRowResult rr = lay->takeRow(r);
|
||||
if (rr.fieldItem) {delete rr.fieldItem->widget(); delete rr.fieldItem;}
|
||||
if (rr.labelItem) {delete rr.labelItem->widget(); delete rr.labelItem;}
|
||||
if (rr.fieldItem) {
|
||||
delete rr.fieldItem->widget();
|
||||
delete rr.fieldItem;
|
||||
}
|
||||
if (rr.labelItem) {
|
||||
delete rr.labelItem->widget();
|
||||
delete rr.labelItem;
|
||||
}
|
||||
#else
|
||||
piForTimes(2) {
|
||||
QLayoutItem * i = lay->itemAt(r + r);
|
||||
lay->removeItem(i);
|
||||
if (i) {delete i->widget(); delete i;}
|
||||
if (i) {
|
||||
delete i->widget();
|
||||
delete i;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void KDockWidget::rename() {
|
||||
QString nn = QInputDialog::getText(this, tr("Rename area"), tr("New area name:"),
|
||||
QLineEdit::Normal, windowTitle());
|
||||
QString nn = QInputDialog::getText(this, tr("Rename area"), tr("New area name:"), QLineEdit::Normal, windowTitle());
|
||||
if (nn.isEmpty()) return;
|
||||
setWindowTitle(nn);
|
||||
}
|
||||
@@ -212,14 +220,11 @@ void KDockWidget::removeK() {
|
||||
int ind = a->data().toInt();
|
||||
if (ind < 0 || ind >= k_list.size_s()) return;
|
||||
k_list.remove(ind);
|
||||
if (ind >= 0 && ind < info_list.size())
|
||||
info_list.remove(ind);
|
||||
if (ind >= 0 && ind < info_list.size()) info_list.remove(ind);
|
||||
removeRow(ind);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CDDirectK::CDDirectK(QWidget * parent): QWidget(parent), Ui::CDDirectK() {
|
||||
setupUi(this);
|
||||
da = new QMainWindow();
|
||||
@@ -229,8 +234,7 @@ CDDirectK::CDDirectK(QWidget * parent) : QWidget(parent), Ui::CDDirectK() {
|
||||
}
|
||||
|
||||
|
||||
CDDirectK::~CDDirectK() {
|
||||
}
|
||||
CDDirectK::~CDDirectK() {}
|
||||
|
||||
|
||||
void CDDirectK::reset() {
|
||||
@@ -245,9 +249,7 @@ QByteArray CDDirectK::save() const {
|
||||
foreach(KDockWidget * d, docks) {
|
||||
dstates << d->save();
|
||||
}
|
||||
cs.add(1, docks.size())
|
||||
.add(2, dstates)
|
||||
.add(3, da->saveState());
|
||||
cs.add(1, docks.size()).add(2, dstates).add(3, da->saveState());
|
||||
return cs.data();
|
||||
}
|
||||
|
||||
@@ -260,8 +262,7 @@ void CDDirectK::load(QByteArray ba) {
|
||||
switch (cs.read()) {
|
||||
case 1: {
|
||||
int s = cs.getData<int>();
|
||||
piForTimes (s)
|
||||
addArea();
|
||||
piForTimes(s) addArea();
|
||||
} break;
|
||||
case 2: {
|
||||
QVector<QByteArray> dstates = cs.getData<QVector<QByteArray>>();
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#ifndef CDDIRECTK_H
|
||||
#define CDDIRECTK_H
|
||||
|
||||
#include "cddirectk_type_dialog.h"
|
||||
#include "cdgraphics.h"
|
||||
#include "ui_cddirectk.h"
|
||||
#include "cddirectk_type_dialog.h"
|
||||
|
||||
class QFormLayout;
|
||||
|
||||
|
||||
class KDockWidget: public QDockWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KDockWidget(QString title = QString(), QMainWindow * p = 0);
|
||||
|
||||
@@ -39,15 +40,14 @@ private slots:
|
||||
|
||||
signals:
|
||||
void removeRequest();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CDDirectK: public QWidget, public Ui::CDDirectK
|
||||
{
|
||||
class CDDirectK
|
||||
: public QWidget
|
||||
, public Ui::CDDirectK {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CDDirectK(QWidget * parent = 0);
|
||||
~CDDirectK();
|
||||
@@ -71,7 +71,6 @@ private slots:
|
||||
void on_buttonRemoveAll_clicked();
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // CDDIRECTK_H
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "cddirectk_type_dialog.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "piqt.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_model.h"
|
||||
#include "piqt.h"
|
||||
#include "spinslider.h"
|
||||
#include "qvariantedit.h"
|
||||
#include "spinslider.h"
|
||||
|
||||
|
||||
CDDirectKTypeDialog::CDDirectKTypeDialog(QWidget * parent): QDialog(parent), Ui::CDDirectKTypeDialog() {
|
||||
@@ -12,8 +13,7 @@ CDDirectKTypeDialog::CDDirectKTypeDialog(QWidget * parent) : QDialog(parent), Ui
|
||||
}
|
||||
|
||||
|
||||
CDDirectKTypeDialog::~CDDirectKTypeDialog() {
|
||||
}
|
||||
CDDirectKTypeDialog::~CDDirectKTypeDialog() {}
|
||||
|
||||
|
||||
CDDirectKTypeDialog::TypeInfo CDDirectKTypeDialog::getType() const {
|
||||
@@ -30,8 +30,6 @@ CDDirectKTypeDialog::TypeInfo CDDirectKTypeDialog::getType() const {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CDDirectKTypeDialog::TypeInfo::TypeInfo(int type_) {
|
||||
type = type_;
|
||||
params_d.resize(4);
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
#ifndef CDDIRECTK_TYPE_DIALOG_H
|
||||
#define CDDIRECTK_TYPE_DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_cddirectk_type_dialog.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class CDDirectKTypeDialog: public QDialog, public Ui::CDDirectKTypeDialog
|
||||
{
|
||||
|
||||
class CDDirectKTypeDialog
|
||||
: public QDialog
|
||||
, public Ui::CDDirectKTypeDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CDDirectKTypeDialog(QWidget * parent = 0);
|
||||
~CDDirectKTypeDialog();
|
||||
@@ -23,13 +26,11 @@ public:
|
||||
TypeInfo getType() const;
|
||||
|
||||
private:
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
inline QDataStream & operator<<(QDataStream & s, const CDDirectKTypeDialog::TypeInfo & v) {
|
||||
|
||||
@@ -2,18 +2,19 @@
|
||||
// #include "ui_qcd_graphic.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_model.h"
|
||||
#include "qcd_graphic.h"
|
||||
#include "graphic.h"
|
||||
#include "piqt.h"
|
||||
#include <QMimeData>
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_graphic.h"
|
||||
#include "qcd_model.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDragMoveEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QMainWindow>
|
||||
#include <QDockWidget>
|
||||
#include <QInputDialog>
|
||||
#include <QMainWindow>
|
||||
#include <QMimeData>
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
@@ -34,8 +35,6 @@ PIVector<PIDeque<int> > CDUtils::setList(const QStringList & l) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
GDockWidget::GDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) {
|
||||
da = p;
|
||||
menu = new QMenu(this);
|
||||
@@ -188,8 +187,7 @@ CDGraphicWidget * GDockWidget::viewportGraphic(QObject * o) const {
|
||||
|
||||
|
||||
void GDockWidget::rename() {
|
||||
QString nn = QInputDialog::getText(this, tr("Rename area"), tr("New area name:"),
|
||||
QLineEdit::Normal, windowTitle());
|
||||
QString nn = QInputDialog::getText(this, tr("Rename area"), tr("New area name:"), QLineEdit::Normal, windowTitle());
|
||||
if (nn.isEmpty()) return;
|
||||
setWindowTitle(nn);
|
||||
}
|
||||
@@ -205,8 +203,6 @@ void GDockWidget::removeX() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CDGraphics::CDGraphics(QWidget * parent): QWidget(parent), Ui::CDGraphics() {
|
||||
setupUi(this);
|
||||
da = new QMainWindow();
|
||||
@@ -216,8 +212,7 @@ CDGraphics::CDGraphics(QWidget * parent) : QWidget(parent), Ui::CDGraphics() {
|
||||
}
|
||||
|
||||
|
||||
CDGraphics::~CDGraphics() {
|
||||
}
|
||||
CDGraphics::~CDGraphics() {}
|
||||
|
||||
|
||||
void CDGraphics::reset() {
|
||||
@@ -232,9 +227,7 @@ QByteArray CDGraphics::save() const {
|
||||
foreach(GDockWidget * d, docks) {
|
||||
dstates << d->save();
|
||||
}
|
||||
cs.add(1, docks.size())
|
||||
.add(2, dstates)
|
||||
.add(3, da->saveState());
|
||||
cs.add(1, docks.size()).add(2, dstates).add(3, da->saveState());
|
||||
X.lock();
|
||||
cs.add(4, getList(X.enabledList()));
|
||||
X.unlock();
|
||||
@@ -251,8 +244,7 @@ void CDGraphics::load(QByteArray ba) {
|
||||
switch (cs.read()) {
|
||||
case 1: {
|
||||
int s = cs.getData<int>();
|
||||
piForTimes (s)
|
||||
addGraphic();
|
||||
piForTimes(s) addGraphic();
|
||||
} break;
|
||||
case 2: {
|
||||
QVector<QByteArray> dstates = cs.getData<QVector<QByteArray>>();
|
||||
@@ -265,9 +257,7 @@ void CDGraphics::load(QByteArray ba) {
|
||||
X.setEnabledList(setList(cs.getData<QStringList>()));
|
||||
X.unlock();
|
||||
break;
|
||||
case 5:
|
||||
buttonConfigVisible->setChecked(cs.getData<bool>());
|
||||
break;
|
||||
case 5: buttonConfigVisible->setChecked(cs.getData<bool>()); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -277,8 +267,7 @@ void CDGraphics::load(QByteArray ba) {
|
||||
GDockWidget * CDGraphics::graphicDock(Graphic * o) const {
|
||||
if (!o) return 0;
|
||||
foreach(GDockWidget * d, docks)
|
||||
if (d->widget() == o)
|
||||
return d;
|
||||
if (d->widget() == o) return d;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#ifndef CDGRAPHICS_H
|
||||
#define CDGRAPHICS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "qcd_graphic.h"
|
||||
#include "ui_cdgraphics.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QMenu>
|
||||
#include "ui_cdgraphics.h"
|
||||
#include "qcd_graphic.h"
|
||||
#include <QWidget>
|
||||
#include <pistring.h>
|
||||
|
||||
namespace CDUtils {
|
||||
@@ -13,16 +14,15 @@ namespace CDUtils {
|
||||
class CDSection;
|
||||
QStringList getList(const PIVector<PIDeque<int>> & x_list);
|
||||
PIVector<PIDeque<int>> setList(const QStringList & l);
|
||||
}
|
||||
} // namespace CDUtils
|
||||
|
||||
class QMainWindow;
|
||||
class Graphic;
|
||||
|
||||
|
||||
|
||||
|
||||
class GDockWidget: public QDockWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GDockWidget(QString title = QString(), QMainWindow * p = 0);
|
||||
|
||||
@@ -50,15 +50,14 @@ private slots:
|
||||
|
||||
signals:
|
||||
void removeRequest();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CDGraphics : public QWidget, public Ui::CDGraphics
|
||||
{
|
||||
class CDGraphics
|
||||
: public QWidget
|
||||
, public Ui::CDGraphics {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CDGraphics(QWidget * parent = 0);
|
||||
~CDGraphics();
|
||||
@@ -86,7 +85,6 @@ private slots:
|
||||
void on_buttonRemoveAll_clicked();
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // CDGRAPHICS_H
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
#include "edockwidget.h"
|
||||
#include "cdpultwindow.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_view.h"
|
||||
#include "qcd_model.h"
|
||||
#include "qcd_modedialog.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "chunkstream.h"
|
||||
#include "qvariantedit.h"
|
||||
#include "edockwidget.h"
|
||||
#include "piqt.h"
|
||||
#include "piqt_highlighter.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_modedialog.h"
|
||||
#include "qcd_model.h"
|
||||
#include "qcd_view.h"
|
||||
#include "qcodeedit.h"
|
||||
#include "qvariantedit.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QScrollBar>
|
||||
#include <QImageReader>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
@@ -59,13 +61,11 @@ CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWin
|
||||
QCDCore::instance()->bindWidget(widgetK->view);
|
||||
QCDCore::instance()->setDirectKEnabled(true);
|
||||
X.start();
|
||||
if (windowState() == Qt::WindowMinimized)
|
||||
setWindowState(Qt::WindowNoState);
|
||||
if (windowState() == Qt::WindowMinimized) setWindowState(Qt::WindowNoState);
|
||||
}
|
||||
|
||||
|
||||
CDPultWindow::~CDPultWindow() {
|
||||
}
|
||||
CDPultWindow::~CDPultWindow() {}
|
||||
|
||||
|
||||
void CDPultWindow::loadFile(const QString & fp) {
|
||||
@@ -87,8 +87,7 @@ void CDPultWindow::apply(bool sessions) {
|
||||
if (sessions) {
|
||||
widgetGraphics->load(session_gr);
|
||||
widgetDirectK->load(session_dk);
|
||||
if (!session_mw.isEmpty())
|
||||
restoreState(session_mw);
|
||||
if (!session_mw.isEmpty()) restoreState(session_mw);
|
||||
X.lock();
|
||||
PIVector<PIDeque<int>> x_list = X.enabledList();
|
||||
X.unlock();
|
||||
@@ -107,8 +106,7 @@ void CDPultWindow::apply(bool sessions) {
|
||||
|
||||
void CDPultWindow::closeEvent(QCloseEvent * e) {
|
||||
EMainWindow::closeEvent(e);
|
||||
if (!e->isAccepted())
|
||||
return;
|
||||
if (!e->isAccepted()) return;
|
||||
QApplication::closeAllWindows();
|
||||
session.save();
|
||||
session.setFile(QString());
|
||||
@@ -141,8 +139,7 @@ bool CDPultWindow::load(const QString & path) {
|
||||
checkHasM->setChecked(conf.getValue("has_m").toBool());
|
||||
checkDefaultConfig->setChecked(conf.getValue("default_config").toBool());
|
||||
codeConfig->setText(QByteArray2QString(conf.getValue("config").toByteArray()));
|
||||
if (codeConfig->text().isEmpty())
|
||||
codeConfig->setText(def_config);
|
||||
if (codeConfig->text().isEmpty()) codeConfig->setText(def_config);
|
||||
session_gr = conf.getValue("session_gr").toByteArray();
|
||||
session_dk = conf.getValue("session_dk").toByteArray();
|
||||
session_mw = conf.getValue("session_mw").toByteArray();
|
||||
@@ -231,8 +228,7 @@ void CDPultWindow::messageReceived(QString path, int type, QString msg) {
|
||||
MessageType mt = (MessageType)type;
|
||||
const CDType & t(M.root()[CDCore::stringToPath(Q2PIString(path))]);
|
||||
if (t.cd_type() != CDType::cdM) return;
|
||||
if (mt == MessageBox)
|
||||
QMessageBox::information(this, windowTitle(), QString("[%1]\n%2").arg(PI2QString(t.name()), msg));
|
||||
if (mt == MessageBox) QMessageBox::information(this, windowTitle(), QString("[%1]\n%2").arg(PI2QString(t.name()), msg));
|
||||
}
|
||||
|
||||
|
||||
@@ -262,13 +258,15 @@ void CDPultWindow::on_editFileK_valueChanged(const QVariant & p) {
|
||||
}
|
||||
if (!fi.path().isEmpty() && fi.path() != ".") {
|
||||
dir = fi.path();
|
||||
if (!dir.endsWith("/"))
|
||||
dir += "/";
|
||||
if (!dir.endsWith("/")) dir += "/";
|
||||
}
|
||||
QAD::File f = editFileK->value().value<QAD::File>();
|
||||
f.file = dir + xn + dot + ext; editFileX->setValue(QVariant::fromValue(f));
|
||||
f.file = dir + cn + dot + ext; editFileC->setValue(QVariant::fromValue(f));
|
||||
f.file = dir + mn + dot + ext; editFileM->setValue(QVariant::fromValue(f));
|
||||
f.file = dir + xn + dot + ext;
|
||||
editFileX->setValue(QVariant::fromValue(f));
|
||||
f.file = dir + cn + dot + ext;
|
||||
editFileC->setValue(QVariant::fromValue(f));
|
||||
f.file = dir + mn + dot + ext;
|
||||
editFileM->setValue(QVariant::fromValue(f));
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +282,9 @@ void CDPultWindow::on_lineSessionName_textChanged(const QString & t) {
|
||||
|
||||
void CDPultWindow::on_buttonIcon_clicked() {
|
||||
QList<QByteArray> ifl = QImageReader::supportedImageFormats();
|
||||
QStringList sfl; foreach (QByteArray s, ifl) sfl << ("*." + QString(s).toLower());
|
||||
QStringList sfl;
|
||||
foreach(QByteArray s, ifl)
|
||||
sfl << ("*." + QString(s).toLower());
|
||||
QString f = QFileDialog::getOpenFileName(this, tr("Select icon"), last_icon, tr("Images") + " (" + sfl.join(" ") + ")");
|
||||
if (f.isEmpty()) return;
|
||||
last_icon = f;
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
#ifndef CDPULTWINDOW_H
|
||||
#define CDPULTWINDOW_H
|
||||
|
||||
#include "emainwindow.h"
|
||||
#include "ui_cdpultwindow.h"
|
||||
#include "cdviewwidget.h"
|
||||
#include "ribbon.h"
|
||||
#include "emainwindow.h"
|
||||
#include "piobject.h"
|
||||
#include "ribbon.h"
|
||||
#include "ui_cdpultwindow.h"
|
||||
|
||||
|
||||
class CDPultWindow : public EMainWindow, public Ui::CDPultWindow
|
||||
{
|
||||
class CDPultWindow
|
||||
: public EMainWindow
|
||||
, public Ui::CDPultWindow {
|
||||
Q_OBJECT
|
||||
Q_ENUMS(LogIcon)
|
||||
public:
|
||||
|
||||
public:
|
||||
explicit CDPultWindow(QWidget * parent = 0);
|
||||
~CDPultWindow();
|
||||
void loadFile(const QString & fp);
|
||||
void apply(bool sessions);
|
||||
|
||||
private:
|
||||
|
||||
void closeEvent(QCloseEvent *);
|
||||
void reset(bool full = false);
|
||||
bool load(const QString & path);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "cdviewwidget.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_model.h"
|
||||
#include "qcd_modedialog.h"
|
||||
#include "qcd_model.h"
|
||||
#include "qvariantedit.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
|
||||
@@ -17,8 +19,7 @@ CDViewWidget::CDViewWidget(QWidget * parent) : QWidget(parent), Ui::CDViewWidget
|
||||
}
|
||||
|
||||
|
||||
CDViewWidget::~CDViewWidget() {
|
||||
}
|
||||
CDViewWidget::~CDViewWidget() {}
|
||||
|
||||
|
||||
void CDViewWidget::reset() {
|
||||
@@ -41,14 +42,20 @@ void CDViewWidget::setFile(const QString & f) {
|
||||
|
||||
|
||||
void CDViewWidget::on_buttonSend_clicked() {
|
||||
if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;}
|
||||
if (view->inProgress()) {
|
||||
addToLog(WaitIcon, "processing...");
|
||||
return;
|
||||
}
|
||||
addToLog(WaitIcon, "Sending " + tl_u + "...");
|
||||
view->send();
|
||||
}
|
||||
|
||||
|
||||
void CDViewWidget::on_buttonReceive_clicked() {
|
||||
if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;}
|
||||
if (view->inProgress()) {
|
||||
addToLog(WaitIcon, "processing...");
|
||||
return;
|
||||
}
|
||||
addToLog(WaitIcon, "Receiving " + tl_u + "...");
|
||||
view->receive();
|
||||
}
|
||||
@@ -65,7 +72,9 @@ void CDViewWidget::on_buttonSave_clicked() {
|
||||
|
||||
|
||||
void CDViewWidget::on_buttonParse_clicked() {
|
||||
QString path = QFileDialog::getOpenFileName(this, "Select header file", "",
|
||||
QString path = QFileDialog::getOpenFileName(this,
|
||||
"Select header file",
|
||||
"",
|
||||
QString("%1 Description(%2_description.h);;Headers(*.h)").arg(tl_u, tl_l));
|
||||
if (path.isEmpty()) return;
|
||||
CDUtils::UpdateModeFlags mode = CDUtils::SaveByName;
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
#ifndef CDVIEWWIDGET_H
|
||||
#define CDVIEWWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_cdviewwidget.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class CDViewWidget : public QWidget, public Ui::CDViewWidget
|
||||
{
|
||||
|
||||
class CDViewWidget
|
||||
: public QWidget
|
||||
, public Ui::CDViewWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CDViewWidget(QWidget * parent = 0);
|
||||
~CDViewWidget();
|
||||
|
||||
enum LogIcon {NoIcon, OKIcon, FailIcon, WaitIcon};
|
||||
enum LogIcon {
|
||||
NoIcon,
|
||||
OKIcon,
|
||||
FailIcon,
|
||||
WaitIcon
|
||||
};
|
||||
|
||||
void reset();
|
||||
void setType(int t);
|
||||
@@ -35,7 +43,6 @@ private slots:
|
||||
|
||||
signals:
|
||||
void addToLog(CDViewWidget::LogIcon icon, const QString & msg);
|
||||
|
||||
};
|
||||
|
||||
#endif // CDVIEWWIDGET_H
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include <QApplication>
|
||||
#include "cdpultwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
enableHighDPI();
|
||||
CDPultWindow w;
|
||||
w.show();
|
||||
if (a.arguments().size() > 1)
|
||||
w.loadFile(a.arguments()[1]);
|
||||
if (a.arguments().size() > 1) w.loadFile(a.arguments()[1]);
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user