valeur=new QMap<QString, QString>;
qDebug()<<"1' connect : "<<connect(signalmap, SIGNAL(mapped(const QString &)), this, SLOT(action(const QString &)));
qDebug()<<"2' connect : "<<connect(this, SIGNAL(datafilled()), this, SLOT(start()));
+ //qDebug()<<"3' connect : "<<connect(CLabel, SIGNAL(longpress()), MainWindow, SLOT(action(QString("edit "+id))););
//a desperated attempt to get the output of my cmd, i've try Qprocess (but don't get it)
//qDebug()<<"3' connect : "<<connect(shell, SIGNAL(readyReadStandardOutput()), this, SLOT(shellReady()));
label=new QLabel;
}
//widget.clear();
}
-CLabel::CLabel( const QString& text, const QSettings & set, QWidget * parent ) : QLabel(parent)
+CLabel::CLabel( const QString& text, const QSettings & set, int tmpid, QWidget * parent ) : QLabel(parent)
{
QString a=set.value(QString("currenttype")).toString();
m_style=set.value(a).toString();
setText(text);
setWordWrap(true);
setLineWidth(5);
+ id=tmpid;
setStyleSheet(m_style);
setScaledContents(true);
settings=&set;
+ parents=parent;
}
CLabel::~CLabel()
{
}
void CLabel::mousePressEvent (QMouseEvent * event )
{
+ t.start();
QString a=settings->value(QString("currenttype")).toString();
QString bb=settings->value(a+QString("before")).toString();
QString ba=settings->value(a+QString("after")).toString();
}
void CLabel::mouseReleaseEvent( QMouseEvent * event )
{
+ int c=t.elapsed();
QString a=settings->value(QString("currenttype")).toString();
QString bb=settings->value(a+QString("before")).toString();
QString ba=settings->value(a+QString("after")).toString();
+ QString tmp("edit "+id);
switch(event->button()){
- case Qt::LeftButton:setStyleSheet(m_style.replace(ba, bb));emit released();break;
+ case Qt::LeftButton:
+ setStyleSheet(m_style.replace(ba, bb));
+ if(c>2000)emit longpress();
+ else emit released();
+ break;
//case Qt::LeftButton:setStyleSheet(m_style.replace(setting->value(setting->value(QString("currenttype")).toString()+"after").toString(), setting->value(QString("currenttype")).toString()+"before"));emit released();break;
}
conf->setValue(QString("choosebuttons"), QVariant("select id,label from buttons where keyword like ? order by label;"));
conf->setValue(QString("addbuttons"), QVariant("insert into buttons (keyword, label, action) values (:keyword, :label, :action)"));
conf->setValue(QString("addraw"), QVariant("INSERT INTO raw (date, texte) VALUES (:date, :txt);"));
- conf->setValue(QString("getbuttons"), QVariant("select label,action from buttons where keyword like ? order by label;"));
+ conf->setValue(QString("getbuttons"), QVariant("select label,action,id from buttons where keyword like ? order by label;"));
conf->setValue(QString("editbuttons"), QVariant("select id,keyword,label,action from buttons where id=?;"));
conf->setValue(QString("updatebuttons"), QVariant("update buttons set keyword=?, label=?, action=? where id=?;"));
conf->setValue(QString("deletebuttons"), QVariant("delete from buttons where id=?"));
return -1;
}
int MainWindow::exec2(const QList<QString> & a){
- qDebug()<<"exec("<<a[0]<<") size="<<a.size();
+ qDebug()<<"exec("<<a[0]<<") size="<<a.size()<<", q->prepare: "<<qq->prepare(a[0]);
qq->prepare(a[0]);
for (int j=1; j<a.size(); j++){
qq->bindValue(j-1, a[j]);
if(a=="")c=context+" : "+entry;
else c=context+", "+a+" : "+entry;
QList<QString> d({conf->value(QString("addraw")).toString(), time, c});
- if(!exec(d))qDebug()<<"exec don't works (entry(QString))";
+ if(!exec2(d))qDebug()<<"exec don't works (entry(QString))";
QSqlError b=q->lastError();
if (b.isValid())qDebug()<<"q->lastError():"<<b.text();
}
tmpfile=QFileDialog::getOpenFileName();
a.replace(QString("!file!"),tmpfile);
};
-
+ /*if(a.contains(QString("!label"))){
+ a.replace(QString("!label!"), label->text());
+ };*/
insert(tmp, b, c, a);
return;
}
//while(q->next()){
printItem(*q);
//}
+ showExpanded();
}
void MainWindow::chooseDB(){
QString b;
bool MainWindow::printItem(const QSqlQuery & a){
int labCol = 0;//r.indexOf("label");
int actCol = 1;//r.indexOf("action");
+ int idcol = 2;//r.indexOf("id");
int i=0;
qDebug()<<"printItem()";
if(page){
};
do{
int tmp=0;
- if(a.isValid())tmp=addWidget(a.value(actCol).toString(), new CLabel(a.value(labCol).toString(), *conf));
+ if(a.isValid())tmp=addWidget(a.value(actCol).toString(), new CLabel(a.value(labCol).toString(), *conf, a.value(idcol).toInt()));
if(tmp==1){
addWidget(QString("nextpage"), new CLabel(trUtf8("Next"), *conf));
return 1;
i++;
}while(a.next());
qDebug()<<"end printItem : "<<i<<" button(s) way.size()"<<way.size()<<" page : "<<page;
- showExpanded();
+ //showExpanded();
return 0;
}
void MainWindow::get2(const QString & d, const QString &b){