diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index a82f3e93c..99e61ffbb 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -51,6 +51,7 @@ HEADERS += rshare.h \ gui/StartDialog.h \ gui/ChatDialog.h \ gui/BlogDialog.h \ + gui/CalDialog.h \ gui/NetworkDialog.h \ gui/GenCertDialog.h \ gui/TransfersDialog.h \ @@ -152,6 +153,7 @@ HEADERS += rshare.h \ FORMS += gui/ChatDialog.ui \ gui/BlogDialog.ui \ + gui/CalDialog.ui \ gui/StartDialog.ui \ gui/GenCertDialog.ui \ gui/NetworkDialog.ui \ @@ -220,6 +222,7 @@ SOURCES += main.cpp \ gui/GenCertDialog.cpp \ gui/ChatDialog.cpp \ gui/BlogDialog.cpp \ + gui/CalDialog.cpp \ gui/NetworkDialog.cpp \ gui/TransfersDialog.cpp \ gui/graphframe.cpp \ diff --git a/retroshare-gui/src/gui/ApplicationWindow.cpp b/retroshare-gui/src/gui/ApplicationWindow.cpp index c614ba7a7..4228ad1c3 100644 --- a/retroshare-gui/src/gui/ApplicationWindow.cpp +++ b/retroshare-gui/src/gui/ApplicationWindow.cpp @@ -47,6 +47,7 @@ #include "ForumsDialog.h" #include "channels/channelsDialog.h" #include "BlogDialog.h" +#include "CalDialog.h" /* for smplayer */ #include "smplayer.h" @@ -72,6 +73,7 @@ #define IMAGE_RSM16 ":/images/rsmessenger16.png" #define IMAGE_CLOSE ":/images/close_normal.png" #define IMAGE_SMPLAYER ":/images/smplayer_icon32.png" +#define IMAGE_CALENDAR ":/images/calendar.png" /* Keys for UI Preferences */ @@ -118,6 +120,10 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags) BlogDialog *blogDialog = NULL; ui.stackPages->add(blogDialog = new BlogDialog(ui.stackPages), createPageAction(QIcon(IMAGE_NETWORK), tr("Blog Feed"), grp)); + + CalDialog *calDialog = NULL; + ui.stackPages->add(calDialog = new CalDialog(ui.stackPages), + createPageAction(QIcon(IMAGE_CALENDAR), tr("Shared Calendars"), grp)); diff --git a/retroshare-gui/src/gui/CalDialog.cpp b/retroshare-gui/src/gui/CalDialog.cpp new file mode 100644 index 000000000..38a8d484a --- /dev/null +++ b/retroshare-gui/src/gui/CalDialog.cpp @@ -0,0 +1,136 @@ +/**************************************************************** + * RetroShare is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#include +#include +#include + +#include +#include + +#include "common/vmessagebox.h" + +//#include "rshare.h" +#include "CalDialog.h" +//#include "rsiface/rspeers.h" +//#include "rsiface/rsrank.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +/** Constructor */ +CalDialog::CalDialog(QWidget *parent) +: MainPage(parent) +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + //declare local variables for GUI items + name = ui.lne_name; + location = ui.lne_location; + status = ui.cbx_status; + calendarList = ui.lst_calList; + + //Set GUI Item Properties + location->setEnabled(false); + + //Create GUI Connections + connect(ui.btn_add,SIGNAL(clicked()),this,SLOT(addItem())); + connect(ui.btn_addFile,SIGNAL(clicked()),this,SLOT(addFile())); + connect(ui.lst_calList,SIGNAL(itemPressed(QListWidgetItem*)),this,SLOT(setDetails(QListWidgetItem*))); + connect(ui.btn_remove,SIGNAL(clicked()),this,SLOT(removeItem())); +} + +void CalDialog::addItem() +{ + itemDetails = new CalItem(); + if(name->text() != QString("")) + itemDetails->name = name->text(); + if(location->text() != QString("")) + itemDetails->location = QString(location->text()); + itemDetails->status = status->currentIndex(); + + //Add Item to Calendar Item Map + calItems.insert(itemDetails->name, *itemDetails); + clearDetails(); //Clear Textbox Details (and itemDetails pointer) + updateList(); //Update listWidget with new map data. +} + +void CalDialog::removeItem() +{ + QListWidgetItem* item = calendarList->currentItem(); + calItems.remove(item->text()); + clearDetails(); + updateList(); +} + +void CalDialog::updateList() +{ + calendarList->clear(); //Clear existing items + //Rebuild list from Map + QMap::iterator it; + for(it = calItems.begin();it != calItems.end();++it) + calendarList->addItem(it.key()); +} + +void CalDialog::clearDetails() +{ + name->setText(""); + location->setText(""); + status->setCurrentIndex(0); + itemDetails = NULL; +} + +void CalDialog::addFile() +{ + //Prompt for ICS calendar file + QStringList file = QFileDialog::getOpenFileNames(this, + "Select calendar to share",location->text(), "Calendars (*.ics)"); + + //Populate location LineEdit if file selected + if(!file.empty()) + location->setText(*file.begin()); +} + +void CalDialog::setDetails(QListWidgetItem* item) +{ + clearDetails(); + QMap::iterator it = calItems.find(item->text()); + CalItem temp = it.value(); + name->setText(temp.name); + location->setText(temp.location); + status->setCurrentIndex(temp.status); +} diff --git a/retroshare-gui/src/gui/CalDialog.h b/retroshare-gui/src/gui/CalDialog.h new file mode 100644 index 000000000..8a958852a --- /dev/null +++ b/retroshare-gui/src/gui/CalDialog.h @@ -0,0 +1,72 @@ +/**************************************************************** + * RetroShare GUI is distributed under the following license: + * + * Copyright (C) 2008 Robert Fernie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + +#ifndef _CALENDAR_DIALOG_H +#define _CALENDAR_DIALOG_H + +#include +#include +#include +#include + +#include "mainpage.h" +#include "ui_CalDialog.h" + +class CalItem +{ + public: + CalItem() {return;} + QString name; + QString location; + int status; +}; + +class CalDialog : public MainPage +{ + Q_OBJECT + +public: +/** Default Constructor */ + CalDialog(QWidget *parent = 0); + +private slots: + void addItem(); + void removeItem(); + void updateList(); + void clearDetails(); + void addFile(); + void setDetails(QListWidgetItem*); + +private: + //Should this be a vector for alphabetical sorting? + QMap calItems; + CalItem *itemDetails; + +/** Qt Designer generated object */ + Ui::CalDialog ui; + + QLineEdit* name; + QLineEdit* location; + QComboBox* status; + QListWidget* calendarList; +}; + +#endif diff --git a/retroshare-gui/src/gui/CalDialog.ui b/retroshare-gui/src/gui/CalDialog.ui new file mode 100644 index 000000000..93dbe8d36 --- /dev/null +++ b/retroshare-gui/src/gui/CalDialog.ui @@ -0,0 +1,276 @@ + + CalDialog + + + + 0 + 0 + 790 + 492 + + + + Form + + + + + 10 + 10 + 771 + 469 + + + + + 0 + 0 + + + + QTabWidget::Rounded + + + 0 + + + Qt::ElideNone + + + + Local Calendars + + + + + 9 + 9 + 201 + 421 + + + + + QLayout::SetMaximumSize + + + + + + 75 + true + + + + Shared Calendar List + + + + + + + + + + + + 220 + 70 + 540 + 301 + + + + + QLayout::SetMaximumSize + + + + + Name: + + + + + + + + + + Location: + + + + + + + QLayout::SetMaximumSize + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + 30 + 0 + + + + + 0 + 16777215 + + + + + 0 + 0 + + + + ... + + + + + + + + + Status: + + + + + + + + 100 + 0 + + + + + 0 + 16777215 + + + + + Private + + + + + Public + + + + + + + + Allow List: + + + + + + + + <Disabled> + + + + + + + + + + 220 + 372 + 540 + 33 + + + + + QLayout::SetMaximumSize + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Add + + + + + + + Remove + + + + + + + + + 220 + 51 + 121 + 21 + + + + + 75 + true + + + + Share Details + + + + + + Peer Calendars + + + + + + + + + diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index b5424e4ae..973176348 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -31,6 +31,7 @@ images/attachment.png images/avatar_background.png images/backgroundimage.png + images/calendar.png images/chat.png images/chat/bar_end.png images/chat/bar_fill.png diff --git a/retroshare-gui/src/gui/images/calendar.png b/retroshare-gui/src/gui/images/calendar.png new file mode 100644 index 000000000..e91b13d73 Binary files /dev/null and b/retroshare-gui/src/gui/images/calendar.png differ