Merge branch 'master' of github.com:ArtemD/SpeedFreak
authorArtem Daniliants <artem@daniliants.com>
Thu, 27 May 2010 08:35:16 +0000 (11:35 +0300)
committerArtem Daniliants <artem@daniliants.com>
Thu, 27 May 2010 08:35:16 +0000 (11:35 +0300)
Client/httpclient.cpp
Client/mainwindow.cpp
Client/usersdialog.cpp
Client/usersdialog.h
Client/usersdialog.ui

index d5049fd..e43f761 100644 (file)
@@ -636,12 +636,27 @@ void HttpClient::ackOfUserInfo()
     file.close();*/
 
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
-    myXmlreader->xmlReadUserInfo(reply);
+    //myXmlreader->xmlReadUserInfo(reply);
 
     //for(int i = 0; i < myXmlreader->usersList->count(); i++)
     //{
     //    myMainw->settingsDialog->sendUsernameToUsersDialog(myXmlreader->usersList->at(i));
     //}
+    QNetworkReply::NetworkError errorcode;
+    errorcode = reply->error();
+    if(errorcode != 0) {
+        qDebug() <<  "errorcode:" << errorcode << reply->errorString();
+        //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories",reply->errorString());
+        if(myMainw->usersDialog)
+            myMainw->usersDialog->setLabelInfoToUser("You're not logged! Please register or log in.");
+    }
+    else {
+        myXmlreader->xmlReadUserInfo(reply);
+        qDebug() <<  "errorcode:" << errorcode << reply->errorString();
+        //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK");
+        if(myMainw->usersDialog)
+            myMainw->usersDialog->setLabelInfoToUser("");
+    }
 }
 
 /**
@@ -668,8 +683,8 @@ void HttpClient::requestUsers()
     //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
 
     //Indicating user
-    //if(myMainw->topResultDialog)
-        //myMainw->topResultDialog->setLabelInfoToUser("Reguesting categories from server");
+    if(myMainw->usersDialog)
+        myMainw->usersDialog->setLabelInfoToUser("Reguesting users from server");
 
     //ackOfUsers();
 }
@@ -703,26 +718,27 @@ void HttpClient::ackOfUsers()
     //    myMainw->topResultDialog->setLabelInfoToUser("");
 
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
-    myXmlreader->xmlReadUsers(reply);
+    //myXmlreader->xmlReadUsers(reply);
 
-    for(int i = 0; i < myXmlreader->usersList->count(); i++)
-    {
-        myMainw->usersDialog->appendUserToList(myXmlreader->usersList->at(i));
-    }
-   /* QNetworkReply::NetworkError errorcode;
+    QNetworkReply::NetworkError errorcode;
     errorcode = reply->error();
     if(errorcode != 0) {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
         //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories",reply->errorString());
-        if(myMainw->topResultDialog)
-            myMainw->topResultDialog->setLabelInfoToUser("You're not logged! Please register or log in.");
+        if(myMainw->usersDialog)
+            myMainw->usersDialog->setLabelInfoToUser("You're not logged! Please register or log in.");
     }
     else {
+        myXmlreader->xmlReadUsers(reply);
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
         //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK");
-        if(myMainw->topResultDialog)
-            myMainw->topResultDialog->setLabelInfoToUser("");
-    }*/
+        if(myMainw->usersDialog)
+            myMainw->usersDialog->setLabelInfoToUser("");
+        for(int i = 0; i < myXmlreader->usersList->count(); i++)
+        {
+            myMainw->usersDialog->appendUserToList(myXmlreader->usersList->at(i));
+        }
+    }
 }
 
 /**
index 27a1f4b..f86681c 100644 (file)
@@ -168,6 +168,9 @@ MainWindow::~MainWindow()
     if(helpDialog)
         delete helpDialog;
 
+    if(usersDialog)
+        delete usersDialog;
+
     if(customButtonAccelerate)
         delete customButtonAccelerate;
     if(customButtonRoute)
@@ -343,6 +346,12 @@ void MainWindow::killDialog()
         delete helpDialog;
         helpDialog = NULL;
     }
+    if(usersDialog)
+    {
+        qDebug() << "__MW kill: usersDialog";
+        delete usersDialog;
+        usersDialog = NULL;
+    }
 }
 
 /**
@@ -464,5 +473,6 @@ void MainWindow::on_pushButtonUsers_clicked()
     connect(usersDialog, SIGNAL(getUserInfo(QString)), this, SLOT(requestGetUserInfo(QString)));
     //connect(usersDialog, SIGNAL(getUsers()), this, SLOT(requestGetUsers()));
     requestGetUsers();
+    connect(usersDialog, SIGNAL(rejected()), this, SLOT(killDialog()));
     usersDialog->show();
 }
index 2d7186c..c61c5d1 100644 (file)
@@ -86,3 +86,8 @@ void UsersDialog::setUserInfo(QStringList *usersInfo)
    }
    //ui->labelDescriptionHeader->setText("Description: " + usersInfo->at(4));
 }
+
+void UsersDialog::setLabelInfoToUser(QString infoText)
+{
+    this->ui->labelInfoToUser->setText(infoText);
+}
index 91e3a82..db291f9 100644 (file)
@@ -15,6 +15,7 @@ public:
     ~UsersDialog();
     void appendUserToList(QString usrname);
     void setUserInfo(QStringList *usersInfo);
+    void setLabelInfoToUser(QString infoText);
 
 protected:
     void changeEvent(QEvent *e);
index 64b7bf8..f716fe4 100644 (file)
     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    </property>
   </widget>
+  <widget class="QLabel" name="labelInfoToUser">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>320</y>
+     <width>671</width>
+     <height>51</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Info label</string>
+   </property>
+  </widget>
  </widget>
  <resources/>
  <connections/>