<< handle.name()
<< QString::number(handle.getTotalSize())
<< GetStatusString(handle.state())
- << QString::number(100*handle.progress() + '%')
+ << QString::number(100*handle.progress())
<< QString::number(handle.downloadRate(), 'f', 2)
<< QString::number(handle.uploadRate(), 'f', 2)
<< QString::number(handle.numSeeds()) + "/"
float prog = handle.progress();
if ((prog-lastProg) >= 0.01 || prog >= 1.0) {
item->setData(3, Qt::DisplayRole,
- QVariant(QString::number(100*prog) + '%'));
+ QVariant(QString::number(100*prog)));
lastProg = prog;
}
tabWidget_(NULL),
dlView_(NULL),
seedView_(NULL),
+ searchWidget_(NULL),
preferencesDialog_(NULL),
settings_(),
pluginDirs_(),
SLOT(setEnabled(bool)));
connect(toolBar, SIGNAL(actionTriggered(QAction*)), this,
SLOT(handleToolBarAction(QAction*)));
-
+ connect (tabWidget_, SIGNAL(tabCloseRequested(int)), this, SLOT(on_tabWidget_tabCloseRequested(int)));
+
connect(&btSession_, SIGNAL(alert(std::auto_ptr<Alert>)),
this, SLOT(on_alert(std::auto_ptr<Alert>)));
}
// ===================== Implements PluginInterface =========================
-bool MainWindow::setGui(QWidget* widget, PluginWidgetType type)
+/// @todo add PluginInterface parameter to request plugin name
+bool MainWindow::setGui(QWidget* widget, PluginWidgetType type, qtrapids::PluginInterface* plugin)
{
#ifdef QTRAPIDS_DEBUG
qDebug() << "MainWindow::setGui():" << dlView_->currentItem();
#endif
+
+ if (plugin && plugin->identifier() == "SearchPlugin") {
+ searchWidget_ = widget;
+ } else {
+ return false;
+ }
+
tabWidget_->addTab(widget, tr("Search"));
return true;
}
-/// @todo Add PluginInterface parameter check which plugin gives the widget to handle appropriately
+/// @todo Add PluginInterface parameter to check which plugin gives the widget, to handle appropriately
void MainWindow::addPluginWidget(QWidget* widget, PluginWidgetType type)
{
#ifdef QTRAPIDS_DEBUG
#endif
if (type == qtrapids::PluginHostInterface::TAB_PAGE) {
- int index = tabWidget_->addTab(widget, tr("Test"));
+ int index = tabWidget_->addTab(widget, tr("Results"));
tabWidget_->setCurrentIndex(index);
//layout_->addWidget(widget);
}
#endif
}
-// =========================== SLOTS =================================
+// =========================== PRIVATE SLOTS =================================
void MainWindow::on_openAction_clicked()
{
QFileDialog *dialog = new QFileDialog( this, "Open torrent file", QString(), tr("Torrent files (*.torrent)"));
btSession_.removeTorrent(handle);
}
+
void MainWindow::on_quitAction_clicked()
{
close();
}
+
void MainWindow::on_preferencesAction_clicked()
{
if (!preferencesDialog_) {
preferencesDialog_->activateWindow();
}
+
void MainWindow::on_aboutAction_clicked()
{
QMessageBox::about(this, tr("About QtRapids"), ABOUT_TEXT);
}
+void MainWindow::on_tabWidget_tabCloseRequested(int index)
+{
+
+ int searchWidgetIndex = tabWidget_->indexOf(searchWidget_);
+
+ // Allow closing other tabs than the first two
+ // TODO The first two may well be closable, just add "show tabs" action for these in the menu
+ if (index != 0 && index != 1 && index != searchWidgetIndex) {
+ QWidget *remove = tabWidget_->widget(index);
+ tabWidget_->removeTab(index);
+ delete remove;
+ remove = NULL;
+ }
+}
+
+
void MainWindow::on_downloadItemSelectionChanged()
{
#ifdef QTRAPIDS_DEBUG
}
}
+
void MainWindow::on_seedItemSelectionChanged()
{
#ifdef QTRAPIDS_DEBUG
}
}
+
void MainWindow::handleToolBarAction(QAction* action)
{
if (action->text() == "Open") {
}
}
+
void MainWindow::on_torrentFileSelected(const QString& file)
{
#ifdef QTRAPIDS_DEBUG
class DownloadView;
class SeedView;
class PreferencesDialog;
+class PluginInterface;
/**
@author Lassi Väätämöinen <lassi.vaatamoinen@ixonos.com>
virtual ~MainWindow();
// Implemented from PluginHostInterface
- virtual bool setGui(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE);
+ virtual bool setGui(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE, qtrapids::PluginInterface* plugin = NULL);
virtual void addPluginWidget(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE);
virtual void addToolbar(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE);
virtual void addToolItem(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE);
void on_preferencesAction_clicked();
void on_aboutAction_clicked();
void on_aboutQtAction_clicked();
+ void on_tabWidget_tabCloseRequested(int index);
void on_downloadItemSelectionChanged();
void on_seedItemSelectionChanged();
void handleToolBarAction(QAction* action);
QTabWidget *tabWidget_;
DownloadView *dlView_;
SeedView *seedView_;
+ QWidget *searchWidget_;
PreferencesDialog *preferencesDialog_;
QSettings settings_;
QList<QDir> pluginDirs_;
/// @brief Sets the plugin GUI element to host application
/// @note It is up to the host application to decide how to manage
/// and show the actual widget.
- virtual bool setGui(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE) = 0;
+ virtual bool setGui(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE, PluginInterface* plugin = NULL) = 0;
/// @brief Adds additional plugin wigdets to the host application.
/// This functio can be called by the plugin recursively, i.e. when GUI events occur
/// @brief Initializes the plugin instance.
virtual void initialize(PluginHostInterface* host, Info info = Info()) = 0;
+
+ /// @brief Returns plugin identifier to be used by the host application
+ /// @returns Plugin identifier as string representation.
+ virtual QString identifier() = 0;
+
virtual QWidget* getGui() = 0;
};
const QString ENGINES_DIR = "engines";
const QString DESCRIPTION_FILENAME = "opensearch.xml";
const QString SEARCH_TERMS_STRING = "{searchTerms}";
-
+ const QString SEARCHPLUGIN_ID = "SearchPlugin";
SearchPlugin::SearchPlugin() :
comboBox_(NULL), searchLine_(NULL),
ParseSearchEngineDescriptions(dir);
}
- host_->setGui(pluginWidget, qtrapids::PluginHostInterface::BASE_WIDGET);
+ host_->setGui(pluginWidget, qtrapids::PluginHostInterface::BASE_WIDGET, this);
}
}
{
return NULL;
}
+
+ QString SearchPlugin::identifier()
+ {
+ return SEARCHPLUGIN_ID;
+ }
void SearchPlugin::on_searchButton_clicked()
/// @brief Initializes the SearchPlugin
/// @param info info.directory is used to search for searchengine description files.
virtual void initialize(PluginHostInterface* host, Info info);
+ virtual QString identifier();
virtual QWidget* getGui();
signals: