00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "core/const.hpp"
00028 #include "core/helpbrowser.hpp"
00029 #include "core/propositiongraph.hpp"
00030 #include "core/svn.hpp"
00031 #include "gui/aboutbox.h"
00032 #include "gui/commitform.h"
00033 #include "gui/settingsform.h"
00034 #include "gui/updateolder.h"
00035 #include <qapplication.h>
00036 #include <qbuttongroup.h>
00037 #include <qspinbox.h>
00038 #include <qstatusbar.h>
00039 #include <qtextbrowser.h>
00040
00041 PropositionGraph* pg;
00042
00043
00044 void Principal::sOpen()
00045 {
00046 pg->load();
00047 }
00048
00052 void Principal::init()
00053 {
00054
00055 svn = new Svn (this);
00056 checkoutMessage = new QLabel("",this);
00057 loginMessage = new QLabel("",this);
00058
00059
00060 setChecked(false);
00061
00062
00063 settings.setPath( "Inter Psi", "Modular Psi" );
00064 setAdress(settings.readEntry("/svn/adress","https://OpenSVN.csie.org/modularpsi/"));
00065 setBranch(settings.readEntry("/svn/branch",""));
00066 setLogin(settings.readEntry( "/svn/login", "anoncvs" ));
00067 setPassword(settings.readEntry("/svn/password",""));
00068 setOrientation(settings.readNumEntry("/graph/orientation",0));
00069
00070
00071 statusBar()->addWidget(statusMessage);
00072 statusBar()->addWidget(loginMessage);
00073 statusBar()->addWidget(checkoutMessage);
00074 statusBar()->addWidget(changeMessage);
00075
00076
00077
00078 sv = new QScrollView(PropositionPage);
00079 sv->addChild(frameInfo);
00080 sv->setGeometry(QRect(2,2,259,362));
00081 sv->setMinimumSize(QSize(252,50));
00082 sv->setFrameShape(QFrame::NoFrame);
00083 sv->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
00084
00085
00086 PropositionPageLayout->addWidget( sv, 0, 0 );
00087
00088
00089 psv = new QScrollView(tab);
00090 psv->addChild(props);
00091 psv->setGeometry(2,2,300,100);
00092 psv->setFrameShape(QFrame::NoFrame);
00093 psv->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
00094
00095
00096 QGridLayout* tabLayout = new QGridLayout( tab, 1, 1, 2, 2, "tabLayout");
00097 tabLayout->addWidget (psv, 0, 0 );
00098
00099
00100 pg = new PropositionGraph();
00101 pg->gui = this;
00102 pg->load();
00103 lastRevision = svn->getLastRev();
00104 }
00105
00106
00107
00108 void Principal::newProposition_activated()
00109 {
00110 pg->setStatus(STATUS_NEWPROP);
00111 }
00112
00113
00114 void Principal::setStatusText(QString text)
00115 {
00116 statusMessage->setText(text);
00117 }
00118
00119
00120 void Principal::fileSaveAction_activated()
00121 {
00122 pg->save("data");
00123
00124 while (!pg->addStack.isEmpty()) {
00125 svn->add(wd + pg->addStack.top()->name() + ".mpsi", false);
00126 pg->addStack.pop();
00127 }
00128
00129 while (!pg->delStack.isEmpty()) {
00130 svn->del(wd + pg->delStack.top()->name() + ".mpsi");
00131 pg->delStack.pop();
00132 }
00133 }
00134
00135
00136 void Principal::changeButton_clicked()
00137 {
00138 if (pg->info() == 1)
00139 pg->update();
00140 else if (pg->info() == 2)
00141 pg->edgeUpdate();
00142 }
00143
00144 void Principal::infoChanged()
00145 {
00146 changeButton->setEnabled(true);
00147 pg->setInfo(1);
00148 }
00149
00150
00151 void Principal::addConexao_activated()
00152 {
00153 pg->setStatus(STATUS_CONN_SOURCE);
00154 }
00155
00156
00157 void Principal::helpAboutAction_activated()
00158 {
00159 AboutBox ab;
00160 ab.licenceBrowser->mimeSourceFactory()->addFilePath(qApp->applicationDirPath());
00161 ab.licenceBrowser->setSource(Principal::tr("cpl1.0-en.html"));
00162 ab.exec();
00163 }
00164
00165
00166 void Principal::delConexao_activated()
00167 {
00168 pg->setStatus(STATUS_EDGE_DELETE);
00169 }
00170
00171
00172
00173 void Principal::delProposition_activated()
00174 {
00175 pg->setStatus(STATUS_PROP_DELETE);
00176 }
00177
00178
00179 void Principal::editConexao_activated()
00180 {
00181 pg->setStatus(STATUS_EDGE_EDIT);
00182 }
00183
00184
00185 void Principal::CVS_activated()
00186 {
00187 svn->revert("data",true);
00188 svn->checkout();
00189 pg->load();
00190 setChecked(true);
00191 }
00192
00193 QString Principal::login()
00194 {
00195 return p_login;
00196 }
00197
00198 QString Principal::password()
00199 {
00200 return p_password;
00201 }
00202
00203 void Principal::setLogin( QString newLogin )
00204 {
00205 p_login = newLogin;
00206 settings.writeEntry( "/svn/login", login() );
00207 loginMessage->setText(newLogin);
00208 if ( newLogin != "anoncvs" && checked)
00209 commitAction->setEnabled(true);
00210 }
00211
00212
00213 void Principal::setPassword( QString newPassword )
00214 {
00215 p_password = newPassword;
00216 settings.writeEntry( "/svn/password",password() );
00217 }
00218
00219 void Principal::setOrientation( int newOrientation )
00220 {
00221 orientation = newOrientation;
00222 settings.writeEntry( "/graph/orientation",orientation );
00223 }
00224
00225 void Principal::setLanguage( int newLanguage )
00226 {
00227 if (newLanguage == 0) setLanguage("en");
00228 else if (newLanguage == 1) setLanguage("pt_br");
00229
00230 }
00231
00232
00233 void Principal::configure_activated()
00234 {
00235 SettingsForm sf;
00236 {
00237 sf.loginEdit->setText(login());
00238 sf.passwordEdit->setText(password());
00239 sf.adressEdit->setText(adress);
00240 sf.graphOrientation->setButton(orientation);
00241 if (language() == "en") sf.languageGroup->setButton(0);
00242 else sf.languageGroup->setButton(1);
00243 if (branch == "") sf.branchGroup->setButton(0);
00244 else
00245 {
00246 sf.branchGroup->setButton(1);
00247 }
00248 }
00249 if (sf.exec())
00250 {
00251 setLogin(sf.loginEdit->text());
00252 setAdress(sf.adressEdit->text());
00253 setPassword(sf.passwordEdit->text());
00254 setOrientation(sf.graphOrientation->selectedId());
00255 setLanguage(sf.languageGroup->selectedId());
00256 }
00257
00258 }
00259
00260
00261 void Principal::commitAction_activated()
00262 {
00263
00264 CommitForm cf;
00265 if (cf.exec())
00266 {
00267 svn->commit("data",cf.logMessage->text());
00268 }
00269
00270 }
00271
00272 void Principal::setChecked( bool checkedStatus )
00273 {
00274 checked = checkedStatus;
00275 if (checkedStatus)
00276 {
00277 checkoutMessage->setText(tr("Checked Out"));
00278 if (login() != "anoncvs")
00279 commitAction->setEnabled(true);
00280 }
00281 else
00282 {
00283 checkoutMessage->setText(tr("NOT checked out"));
00284 commitAction->setEnabled(false);
00285 }
00286 }
00287
00288
00289 void Principal::edgeInfoChanged()
00290 {
00291 changeButton->setEnabled(true);
00292 pg->setInfo(2);
00293 }
00294
00295
00296 void Principal::help_activated()
00297 {
00298 HelpBrowser::showPage("index.html");
00299 }
00300
00301
00302 QString Principal::language()
00303 {
00304 return p_language;
00305 }
00306
00307
00308 void Principal::setLanguage( QString newLang )
00309 {
00310 p_language = newLang;
00311 settings.writeEntry( "language", p_language);
00312 }
00313
00314
00315 void Principal::revertAction_activated()
00316 {
00317 svn->revert("data",true);
00318 }
00319
00320
00321 void Principal::setBranch( QString newBranch )
00322 {
00323 branch = newBranch;
00324 settings.writeEntry( "/svn/branch", branch);
00325 if (branch == "")
00326 wd = "data";
00327 else
00328 wd = "data/branch/" + branch;
00329 }
00330
00331
00332 void Principal::setAdress( QString newAdress )
00333 {
00334 adress = newAdress;
00335 settings.writeEntry( "/svn/adress", adress);
00336 }
00337
00338
00339 void Principal::svnUpdate_to_Older_VersionAction_activated()
00340 {
00341 updateOlder uo;
00342 uo.uoSpin->setMaxValue(lastRevision);
00343 uo.uoSpin->setValue(lastRevision);
00344 QString temp;
00345 temp.setNum(lastRevision);
00346 uo.upLabel->setText(temp);
00347 temp.setNum(uo.uoSpin->value());
00348 if (uo.exec())
00349 {
00350 svn->update(temp);
00351 }
00352
00353 }