akregator/src
listtabwidget.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "listtabwidget.h"
00026 #include "feedlistview.h"
00027 #include "folder.h"
00028 #include "treenode.h"
00029
00030 #include <kmultitabbar.h>
00031
00032 #include <qiconset.h>
00033 #include <qlayout.h>
00034 #include <qmap.h>
00035 #include <qptrlist.h>
00036 #include <qstring.h>
00037 #include <qvaluelist.h>
00038 #include <qwidgetstack.h>
00039
00040 #include <kdebug.h>
00041
00042 namespace Akregator {
00043
00044 class ListTabWidget::ListTabWidgetPrivate
00045 {
00046
00047 public:
00048 int idCounter;
00049 KMultiTabBar* tabBar;
00050 QWidgetStack* stack;
00051 NodeListView* current;
00052 int currentID;
00053 QValueList<NodeListView*> views;
00054 QMap<int, NodeListView*> idToView;
00055 QHBoxLayout* layout;
00056 ViewMode viewMode;
00057 QMap<QWidget*, QString> captions;
00058 };
00059
00060
00061 void ListTabWidget::slotItemUp()
00062 {
00063 if (d->current)
00064 d->current->slotItemUp();
00065 }
00066
00067 void ListTabWidget::slotItemDown()
00068 {
00069 if (d->current)
00070 d->current->slotItemDown();
00071 }
00072
00073 void ListTabWidget::slotItemBegin()
00074 {
00075 if (d->current)
00076 d->current->slotItemBegin();
00077 }
00078
00079 void ListTabWidget::slotItemEnd()
00080 {
00081 if (d->current)
00082 d->current->slotItemEnd();
00083 }
00084
00085 void ListTabWidget::slotItemLeft()
00086 {
00087 if (d->current)
00088 d->current->slotItemLeft();
00089 }
00090
00091 void ListTabWidget::slotItemRight()
00092 {
00093 if (d->current)
00094 d->current->slotItemRight();
00095 }
00096
00097 void ListTabWidget::slotPrevFeed()
00098 {
00099 if (d->current)
00100 d->current->slotPrevFeed();
00101 }
00102
00103 void ListTabWidget::slotNextFeed()
00104 {
00105 if (d->current)
00106 d->current->slotNextFeed();
00107 }
00108
00109 void ListTabWidget::slotPrevUnreadFeed()
00110 {
00111 if (d->current)
00112 d->current->slotPrevUnreadFeed();
00113 }
00114
00115 void ListTabWidget::slotNextUnreadFeed()
00116 {
00117 if (d->current)
00118 d->current->slotNextUnreadFeed();
00119 }
00120
00121 void ListTabWidget::slotRootNodeChanged(NodeListView* view, TreeNode* node)
00122 {
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 }
00137
00138 void ListTabWidget::slotTabClicked(int id)
00139 {
00140 NodeListView* view = d->idToView[id];
00141 if (view)
00142 {
00143 d->stack->raiseWidget(view);
00144 d->current = view;
00145
00146 if (d->currentID >= 0)
00147 d->tabBar->setTab(d->currentID, false);
00148 d->currentID = id;
00149 d->tabBar->setTab(d->currentID, true);
00150
00151 emit signalNodeSelected(d->current->selectedNode());
00152 }
00153 }
00154
00155 ListTabWidget::ListTabWidget(QWidget* parent, const char* name) : QWidget(parent, name), d(new ListTabWidgetPrivate)
00156 {
00157 d->idCounter = 0;
00158 d->current = 0;
00159 d->currentID = -1;
00160 d->viewMode = verticalTabs;
00161 d->layout = new QHBoxLayout(this);
00162
00163 d->tabBar = new KMultiTabBar(KMultiTabBar::Vertical, this);
00164 d->tabBar->setStyle(KMultiTabBar::KDEV3ICON);
00165
00166 d->tabBar->showActiveTabTexts(true);
00167 d->tabBar->setPosition(KMultiTabBar::Left);
00168 d->layout->addWidget(d->tabBar);
00169
00170 d->stack = new QWidgetStack(this);
00171 d->layout->addWidget(d->stack);
00172
00173
00174 }
00175
00176 ListTabWidget::~ListTabWidget()
00177 {
00178 delete d;
00179 d = 0;
00180 }
00181
00182
00183 void ListTabWidget::setViewMode(ViewMode mode)
00184 {
00185 if (mode == d->viewMode)
00186 return;
00187
00188 d->viewMode = mode;
00189
00190
00191 d->tabBar->setHidden(mode == single);
00192 }
00193
00194 ListTabWidget::ViewMode ListTabWidget::viewMode() const
00195 {
00196 return d->viewMode;
00197 }
00198
00199 void ListTabWidget::addView(NodeListView* view, const QString& caption, const QPixmap& icon)
00200 {
00201 d->captions[view] = caption;
00202
00203 view->reparent(d->stack, QPoint(0,0));
00204 d->stack->addWidget(view);
00205
00206 int tabId = d->idCounter++;
00207 d->tabBar->appendTab(icon, tabId, caption);
00208 d->idToView[tabId] = view;
00209 connect(d->tabBar->tab(tabId), SIGNAL(clicked(int)), this, SLOT(slotTabClicked(int)));
00210
00211
00212 connect(view, SIGNAL(signalNodeSelected(TreeNode*)), this, SIGNAL(signalNodeSelected(TreeNode*)));
00213 connect(view, SIGNAL(signalRootNodeChanged(NodeListView*, TreeNode*)), this, SLOT(slotRootNodeChanged(NodeListView*, TreeNode*)));
00214
00215
00216 if (tabId == 0)
00217 {
00218 d->current = view;
00219 d->currentID = tabId;
00220 d->tabBar->setTab(d->currentID, true);
00221 d->stack->raiseWidget(view);
00222 }
00223 }
00224
00225 NodeListView* ListTabWidget::activeView() const
00226 {
00227 return d->current;
00228 }
00229
00230 }
00231
00232 #include "listtabwidget.h"
00233
00234 #include "listtabwidget.moc"
|