1.1 --- a/vymmodel.cpp Tue Jan 05 11:23:12 2010 +0000
1.2 +++ b/vymmodel.cpp Thu Jan 21 11:56:57 2010 +0000
1.3 @@ -14,6 +14,7 @@
1.4 #include "mainwindow.h"
1.5 #include "misc.h"
1.6 #include "parser.h"
1.7 +#include "process.h"
1.8
1.9 #include "warningdialog.h"
1.10 #include "xlinkitem.h"
1.11 @@ -1550,14 +1551,21 @@
1.12 return QString();
1.13 }
1.14
1.15 -void VymModel::setNote(const QString &s) //FIXME-2 savestate missing // FIXME-2 call to VM::updateNoteFlag missing (fix signal handling here)
1.16 -{
1.17 +void VymModel::setNote(const QString &s)
1.18 +{
1.19 + cout << "VM::setNote\n";
1.20 TreeItem *selti=getSelectedItem();
1.21 if (selti)
1.22 {
1.23 + emitNoteHasChanged(selti);
1.24 + saveState(
1.25 + selti,
1.26 + "setNote (\""+selti->getNote()+"\")",
1.27 + selti,
1.28 + "setNote (\""+s+"\")",
1.29 + QString("Set note of %1 ").arg(getObjectName(selti)) );
1.30 + }
1.31 selti->setNote(s);
1.32 - emitNoteHasChanged(selti);
1.33 - }
1.34 }
1.35
1.36 QString VymModel::getNote()
1.37 @@ -1569,6 +1577,42 @@
1.38 return QString();
1.39 }
1.40
1.41 +void VymModel::findDuplicateURLs() // FIXME-3 needs GUI
1.42 +{
1.43 + // Generate map containing _all_ URLs and branches
1.44 + QString u;
1.45 + QMap <QString,BranchItem*> map;
1.46 + BranchItem *cur=NULL;
1.47 + BranchItem *prev=NULL;
1.48 + nextBranch(cur,prev);
1.49 + while (cur)
1.50 + {
1.51 + u=cur->getURL();
1.52 + if (!u.isEmpty() )
1.53 + map.insertMulti (u,cur);
1.54 + nextBranch(cur,prev);
1.55 + }
1.56 +
1.57 + // Extract duplicate URLs
1.58 + QMap <QString, BranchItem*>::const_iterator i=map.constBegin();
1.59 + QMap <QString, BranchItem*>::const_iterator firstdup=map.constEnd(); //invalid
1.60 + while (i != map.constEnd())
1.61 + {
1.62 + if (i!=map.constBegin() && i.key()==firstdup.key())
1.63 + {
1.64 + if ( i-1==firstdup )
1.65 + {
1.66 + cout << firstdup.key().toStdString() << endl;
1.67 + cout << " - "<< firstdup.value() <<" - "<<firstdup.value()->getHeadingStd()<<endl;
1.68 + }
1.69 + cout << " - "<< i.value() <<" - "<<i.value()->getHeadingStd()<<endl;
1.70 + } else
1.71 + firstdup=i;
1.72 +
1.73 + ++i;
1.74 + }
1.75 +}
1.76 +
1.77 BranchItem* VymModel::findText (QString s, bool cs)
1.78 {
1.79 if (!s.isEmpty() && s!=findString)
1.80 @@ -1679,7 +1723,7 @@
1.81 return QString();
1.82 }
1.83
1.84 -QStringList VymModel::getURLs()
1.85 +QStringList VymModel::getURLs(bool ignoreScrolled)
1.86 {
1.87 QStringList urls;
1.88 BranchItem *selbi=getSelectedBranch();
1.89 @@ -1687,7 +1731,8 @@
1.90 BranchItem *prev=NULL;
1.91 while (cur)
1.92 {
1.93 - if (!cur->getURL().isEmpty()) urls.append( cur->getURL());
1.94 + if (!cur->getURL().isEmpty() && !(ignoreScrolled && cur->hasScrolledParent(cur) ))
1.95 + urls.append( cur->getURL());
1.96 cur=nextBranch (cur,prev,true,selbi);
1.97 }
1.98 return urls;
1.99 @@ -2888,7 +2933,77 @@
1.100 {
1.101 QRegExp rx("(\\d+)");
1.102 if (rx.indexIn(url) !=-1)
1.103 - cout << "VM::getBugzillaData bug="<<rx.cap(1).toStdString()<<endl;
1.104 + {
1.105 + QString bugID=rx.cap(1);
1.106 + cout << "VM::getBugzillaData bug="<<bugID.toStdString()<<endl;
1.107 +
1.108 + QString script="test/vym-bug.pl";
1.109 + /*
1.110 + QProgressDialog progress2("Copying files...", "Abort Copy", 0, 40, mainWindow);
1.111 + progress2.setWindowModality(Qt::WindowModal);
1.112 + progress2.setValue (3);
1.113 + progress2.update();
1.114 + QProgressDialog progress ("Contacting Bugzilla...","empty",0,0);
1.115 + progress.setCancelButton (NULL);
1.116 + progress.setWindowModality(Qt::WindowModal);
1.117 + progress.show();
1.118 + progress.update();
1.119 +*/
1.120 + Process p;
1.121 + p.start (script,QStringList()<<bugID);
1.122 + if (!p.waitForStarted())
1.123 + {
1.124 + cout <<"VM::getBugzillaData couldn't start "<<script.toStdString()<<endl;
1.125 + return;
1.126 + }
1.127 + if (!p.waitForFinished())
1.128 + {
1.129 + cout <<"VM::getBugzillaData couldn't finish "<<script.toStdString()<<endl;
1.130 + //progress.hide();
1.131 + return;
1.132 + }
1.133 + //progress.hide();
1.134 + //QByteArray result=p.readAll();
1.135 + QString result=p.getStdout();
1.136 + while (result.endsWith("\n")) result.chop(1);
1.137 + //cout << QString(result).toStdString()<<endl;
1.138 + QString err=p.getErrout();
1.139 + if (!err.isEmpty())
1.140 + {
1.141 + cout << "VM::getBugzillaData Error:\n";
1.142 + cout <<err.toStdString()<<endl;
1.143 + }
1.144 + else if (!result.isEmpty())
1.145 + {
1.146 + QString heading,cdate,mdate,state,whiteboard;
1.147 + QRegExp re("short_desc:(.*)\n");
1.148 + re.setMinimal(true);
1.149 + if (re.indexIn (result) !=-1) heading=re.cap(1);
1.150 +
1.151 + re.setPattern ("creation_ts:(.*)\\s");
1.152 + if (re.indexIn (result) !=-1) cdate=re.cap(1);
1.153 +
1.154 + re.setPattern ("delta_ts:(.*)\\s");
1.155 + if (re.indexIn (result) !=-1) mdate=re.cap(1);
1.156 +
1.157 + re.setPattern ("bug_status:(.*)\n");
1.158 + if (re.indexIn (result) !=-1) state=re.cap(1);
1.159 +
1.160 + re.setPattern ("status_whiteboard:(.*)\n");
1.161 + if (re.indexIn (result) !=-1) whiteboard=re.cap(1);
1.162 +
1.163 + setHeading (bugID + " - " + heading);
1.164 + cout << "VM: heading="<<heading.toStdString()<<endl;
1.165 + cout << "VM: cdate="<<cdate.toStdString()<<endl;
1.166 + cout << "VM: mdate="<<mdate.toStdString()<<endl;
1.167 + cout << "VM: state="<<state.toStdString()<<endl;
1.168 + cout << "VM: wboard="<<whiteboard.toStdString()<<endl;
1.169 +
1.170 + //cout <<"VM::getBugzillaData "<<script.toStdString()<<" returned:\n";
1.171 + //cout <<QString(result).toStdString()<<endl;
1.172 + } else
1.173 + cout << "VM::getBugzillaData "<<script.toStdString()<<" returned nothing\n";
1.174 + }
1.175 }
1.176 }
1.177 }
1.178 @@ -4342,17 +4457,20 @@
1.179
1.180 void VymModel::updateNoteFlag()
1.181 {
1.182 - setChanged();
1.183 TreeItem *selti=getSelectedItem();
1.184 if (selti)
1.185 {
1.186 + if (!mapChanged)
1.187 + {
1.188 + setChanged();
1.189 + updateActions();
1.190 + }
1.191 +
1.192 if (textEditor->isEmpty())
1.193 selti->clearNote();
1.194 else
1.195 selti->setNote (textEditor->getText());
1.196 emitDataHasChanged(selti);
1.197 - emitSelectionChanged();
1.198 -
1.199 }
1.200 }
1.201