- Initial GUI: Main window with two tabs, torrent file open dialog.
authorlvaatamoinen <lassi.vaatamoinen@ixonos.com>
Tue, 20 Oct 2009 10:10:01 +0000 (10:10 +0000)
committerlvaatamoinen <lassi.vaatamoinen@ixonos.com>
Tue, 20 Oct 2009 10:10:01 +0000 (10:10 +0000)
git-svn-id: file:///svnroot/qtrapids/trunk@8 42ac0dd5-4c8c-4c71-bb3e-ecdfe252ffda

qtrapids.kdevelop
src/gui/DownloadView.h
src/gui/MainWindow.cpp
src/gui/MainWindow.h
src/gui/SeedView.cpp
src/gui/SeedView.h
src/gui/gui.pro
src/gui/main.cpp

index b5def60..c8a115f 100644 (file)
       <autoinstall>false</autoinstall>
       <autokdesu>false</autokdesu>
       <envvars/>
+      <runarguments>
+        <qtrapids></qtrapids>
+      </runarguments>
+      <cwd>
+        <qtrapids>/home/vaatala/Projects/qtrapids/trunk</qtrapids>
+      </cwd>
+      <debugarguments>
+        <qtrapids></qtrapids>
+      </debugarguments>
     </run>
     <general>
-      <activedir>src</activedir>
+      <activedir>src/gui</activedir>
     </general>
     <make>
       <abortonerror>true</abortonerror>
     <openfiles/>
   </workspace>
   <kdevfilecreate>
+    <filetypes/>
     <useglobaltypes>
       <type ext="ui" />
+      <type ext="qrc" />
       <type ext="cpp" />
       <type ext="h" />
       <type ext="ts" />
-      <type ext="qrc" />
     </useglobaltypes>
   </kdevfilecreate>
   <kdevdocumentation>
     <projectdoc>
       <docsystem>Doxygen Documentation Collection</docsystem>
       <docurl>qtrapids.tag</docurl>
+      <usermanualurl></usermanualurl>
     </projectdoc>
   </kdevdocumentation>
   <substmap>
index 07ec860..f3d43c5 100644 (file)
@@ -45,18 +45,13 @@ Q_OBJECT
 */
 class DownloadViewItem : public QTreeWidgetItem {
        
-       public:
-               
+       public: 
                DownloadViewItem(QTreeWidget* parent, int type) : 
-                               QTreeWidgetItem(parent, type = QTreeWidgetItem::UserType)
-               {
-               };
+                       QTreeWidgetItem(parent, type = QTreeWidgetItem::UserType) {};
                
                DownloadViewItem(const QStringList& strings, 
-                                                                               int type = QTreeWidgetItem::UserType ) : 
-                       QTreeWidgetItem (strings, type = Type)
-               {
-               };
+                                                                               int type = QTreeWidgetItem::UserType) : 
+                       QTreeWidgetItem (strings, type = Type) {};
                
                
                /// @return An item comprising of string list, suitable for QTableView
@@ -64,11 +59,12 @@ class DownloadViewItem : public QTreeWidgetItem {
                static DownloadViewItem *getHeaderItem()
                {
                        DownloadViewItem *item  
-                               = new DownloadViewItem(QStringList() << "Name" 
+                               = new DownloadViewItem(QStringList() 
+                                       << "Name" 
                                        << "Size" << "Status" 
                                        << "Progress" << "DL speed" 
                                        << "UL speed" << "Seeds/Leechers"
-                                       << "ratio" << "ETA");
+                                       << "Ratio" << "ETA");
                        
                        return item;
                }
index bbd5433..7412e5b 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+
+
+#include <QDebug>
+
+
+#include <QToolBar>
+#include <QAction>
+#include <QFileDialog>
+
+#include "DownloadView.h"
+#include "SeedView.h"
+
 #include "MainWindow.h"
 
+
+
 MainWindow::MainWindow()
 {
+       
+       tabWidget_ = new QTabWidget();
+       
+       /// @todo Exception handling
+       dlView_ = new DownloadView(this);
+       seedView_ = new SeedView(this);
+       
+       tabWidget_->addTab(dlView_, "Downloads");
+       tabWidget_->addTab(seedView_, "Seeds");
+       
+       // Tab widget as central widget.
+       setCentralWidget(tabWidget_);
+       
+       QToolBar *toolBar = new QToolBar();
+       toolBar->addAction("Open");
+       
+       addToolBar(Qt::TopToolBarArea, toolBar);
+       
+       connect(toolBar, SIGNAL(actionTriggered(QAction*)), this, SLOT(handleToolBarAction(QAction*)));
+       
 }
 
 
@@ -29,3 +63,16 @@ MainWindow::~MainWindow()
 }
 
 
+void MainWindow::handleToolBarAction(QAction* action)
+{
+       
+       if (action->text() == "Open") {
+               QFileDialog *dialog = new QFileDialog( this, "Open torrent file", QString(), tr("Torrent files (*.torrent)"));
+               dialog->setFileMode(QFileDialog::ExistingFile);
+               dialog->show();
+       } else {
+       }
+
+
+}
+
index 59b472f..766b659 100644 (file)
@@ -24,6 +24,8 @@
 
 
 class QTabWidget;
+class DownloadView;
+class SeedView;
 
 /**
        @author Lassi Väätämöinen <lassi.vaatamoinen@ixonos.com>
@@ -38,11 +40,12 @@ class MainWindow : public QMainWindow {
                
        public slots:
        private slots:
+               void handleToolBarAction(QAction* action);
                
        private:
                QTabWidget *tabWidget_;
-               
-               
+               DownloadView *dlView_;
+               SeedView *seedView_;
 };
 
 #endif
index 3e8d526..e15621e 100644 (file)
  ***************************************************************************/
 #include "SeedView.h"
 
-SeedView::SeedView(QWidget* parent): QTreeWidget(parent)
+SeedView::SeedView(QWidget* parent):
+       QTreeWidget(parent)
 {
+       setRootIsDecorated(false); // Hide branch lines, making one-level treeview (similar to list)
+       setHeaderItem(SeedViewItem::getHeaderItem());
 }
 
 
index ef42f6b..37d61e0 100644 (file)
@@ -44,4 +44,37 @@ Q_OBJECT
                // ratio 
 };
 
+/**
+       @class DownloadViewItem
+       @brief Represents one item row of DownloadView
+ */
+class SeedViewItem : public QTreeWidgetItem {
+       
+       public:
+               
+               SeedViewItem(QTreeWidget* parent, int type) : 
+                       QTreeWidgetItem(parent, type = QTreeWidgetItem::UserType) {};
+               
+               SeedViewItem(const QStringList& strings, int type = QTreeWidgetItem::UserType ) : 
+                       QTreeWidgetItem (strings, type = Type) {};
+               
+               
+               /// @return An item comprising of string list, suitable for QTableView
+               /// header.
+               static SeedViewItem *getHeaderItem()
+               {
+                       SeedViewItem *item  
+                               = new SeedViewItem(QStringList()
+                                       << "Name" 
+                                       << "Size" << "Status" 
+                                       << "Progress" << "UL speed" << "Seeds/Leechers"
+                                       << "Conn. peers"
+                                       << "Ratio");
+
+                       return item;
+               }
+
+               /// @todo QTorrentHandle as one hidden column
+};
+
 #endif
index 78ba94a..8d105ec 100644 (file)
@@ -11,5 +11,8 @@ TARGET = qtrapids
 
 CONFIG -= release
 
-CONFIG += debug
+CONFIG += debug \
+ qtestlib
+
+DESTDIR = ../../
 
index 0366a84..801ae6d 100644 (file)
  ***************************************************************************/
 #include <QApplication>
 #include <QDebug>
-#include "DownloadView.h"
+#include <QTest>
+//#include "DownloadView.h"
+
+#include "MainWindow.h"
 
 int main(int argc, char *argv[])
 {
+       
+       
      // Q_INIT_RESOURCE(application);
        QApplication app(argc, argv);
+       MainWindow *mainWindow = new MainWindow();
+       mainWindow->show(); 
+       /*
        DownloadView* dlw = new DownloadView(NULL);
       //qtrapids * mw = new qtrapids();
        dlw->show();
@@ -33,8 +41,24 @@ int main(int argc, char *argv[])
                        << "Progress" << "DL speed" 
                        << "UL speed" << "Seeds/Leechers"
                        << "ratio");
-       dlwItem->insertChild(0, new DownloadViewItem(QStringList() << "Name"));
+       DownloadViewItem* dlwItem2 = new DownloadViewItem(QStringList() << "Name" 
+                       << "1000" << "Downloading" 
+                       << "23%" << "11" 
+                       << "0.1" << "0/2"
+                       << "1.10");
+       //dlwItem->insertChild(0, new DownloadViewItem(QStringList() << "Name"));
        dlw->insertTopLevelItem(0,dlwItem);
-       qDebug() << dlw->columnCount();
+       dlw->insertTopLevelItem(1,dlwItem2);
+       
+       for (unsigned i = 0; i < 10; ++i)
+       {
+               DownloadViewItem *editItem = dynamic_cast<DownloadViewItem*>
+                               (dlw->itemAt(QPoint(0,0)));
+               editItem->setData ( 8, Qt::DisplayRole, QVariant("EDITED" + QString::number(i, 'g', 2)));
+               QTest::qSleep(2000);
+       }
+       */
+       
+       
        return app.exec();
 }