Merging r780:786 from trunk to branches/0.3. Plus some work-in-progress.
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 24 Apr 2008 01:07:03 +0000 (01:07 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 24 Apr 2008 01:07:03 +0000 (01:07 +0000)
src/client/client.h
src/client/messagemodel.cpp
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/qtui/qtui.pri
src/qtui/settingspages/networkssettingspage.ui
src/qtui/titlesetter.cpp [new file with mode: 0644]
src/qtui/titlesetter.h [new file with mode: 0644]
src/uisupport/bufferview.cpp
src/uisupport/bufferview.h
version.inc

index e0ad4ec..099d59b 100644 (file)
@@ -35,7 +35,6 @@ class MessageModel;
 class Identity;
 class Network;
 
-
 class AbstractUi;
 class AbstractUiMsg;
 class NetworkModel;
index ea31117..11cd024 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+
+#include "messagemodel.h"
+
+MessageModel::MessageModel(QObject *parent) : QAbstractItemModel(parent) {
+  
+  
+  
+}
+
+MessageModel::~MessageModel() {
+  
+  
+}
+
+QVariant MessageModel::data(const QModelIndex &index, int role) const {
+  int row = index.row();
+  if(row < 0 || row >= _messageList.count()) return QVariant();
+  return _messageList[row]->data(index.column(), role);
+}
+
+bool MessageModel::setData(const QModelIndex &index, const QVariant &value, int role) {
+  int row = index.row();
+  if(row < 0 || row >= _messageList.count()) return false;
+  if(_messageList[row]->setData(index.column(), role)) {
+    emit dataChanged(index, index); // FIXME make msg emit this (too)
+    return true;
+  }
+  return false;
+}
+
+void MessageModel::insertMessage(const Message &msg) {
+  MsgId id = msg.msgId();
+  MessageItem *item = createMessageItem(msg);
+  if(id > )
+    
+}
+
+// returns index of msg with given Id or of the next message after that (i.e., the index where we'd insert this msg)
+int MessageModel::indexForId(MsgId id) {
+  if(!_messageList.count() || id <= _messageList[0]->data(0, MsgIdRole).value<MsgId>()) return 0;
+  if(id > _messageList.last()->data(0, MsgIdRole).value<MsgId>()) return _messageList.count();
+  // binary search
+  int start = 0; int end = _messageList.count()-1;
+  int idx;
+  while(1) {
+    if(start == end) return start;
+    idx = (end + start) / 2;
+    
+}
+
+/**********************************************************************************/
+
index 6dcd8cd..e705654 100644 (file)
 #include "global.h"
 #include "qtuistyle.h"
 
+
 MainWin::MainWin(QtUi *_gui, QWidget *parent)
   : QMainWindow(parent),
     gui(_gui),
     sslLabel(new QLabel()),
+    _titleSetter(this),
     systray(new QSystemTrayIcon(this)),
     activeTrayIcon(":/icons/quassel-icon-active.png"),
     onlineTrayIcon(":/icons/quassel-icon.png"),
@@ -141,13 +143,8 @@ void MainWin::init() {
   ui.bufferWidget->setModel(Client::bufferModel());
   ui.bufferWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
 
-  if(Global::DEBUG) {
-    //showSettingsDlg();
-    //showAboutDlg();
-    //showNetworkDlg();
-    //exit(1);
-  }
-
+  _titleSetter.setModel(Client::bufferModel());
+  _titleSetter.setSelectionModel(Client::bufferModel()->standardSelectionModel());
 }
 
 MainWin::~MainWin() {
@@ -618,6 +615,7 @@ void MainWin::makeTrayIconBlink() {
 }
 
 
+
 void MainWin::clientNetworkCreated(NetworkId id) {
   const Network *net = Client::network(id);
   QAction *act = new QAction(net->networkName(), this);
index f572e1d..96e0c71 100644 (file)
 #include "ui_mainwin.h"
 
 #include "qtui.h"
+#include "titlesetter.h"
 
 #include <QSystemTrayIcon>
 #include <QTimer>
 
+
 class ServerListDlg;
 class CoreConnectDlg;
 class Buffer;
@@ -107,6 +109,8 @@ class MainWin : public QMainWindow {
     QMenu *systrayMenu;
     QLabel *sslLabel;
 
+    TitleSetter _titleSetter;
+
     void setupMenus();
     void setupViews();
     void setupNickWidget();
index abd785e..46b51e9 100644 (file)
@@ -4,12 +4,12 @@ QT_MOD = core gui network
 SRCS += aboutdlg.cpp bufferwidget.cpp chatitem.cpp chatline.cpp chatline-old.cpp chatscene.cpp chatview.cpp chatwidget.cpp \
         coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \
         mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \
-        topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp
+        titlesetter.cpp topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp
 
 HDRS += aboutdlg.h bufferwidget.h chatitem.h chatline.h chatline-old.h chatscene.h chatview.h chatwidget.h \
         coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \
         coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \
-        topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h
+        titlesetter.h topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h
 
 FORMNAMES = aboutdlg.ui mainwin.ui coreaccounteditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \
             settingspagedlg.ui topicwidget.ui debugconsole.ui inputwidget.ui \
index b4d1f33..aae2401 100644 (file)
@@ -5,7 +5,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>736</width>
+    <width>514</width>
     <height>452</height>
    </rect>
   </property>
@@ -171,7 +171,7 @@ Unless you *really* know what you do, leave this as ISO-8859-1!</string>
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>398</width>
+           <width>301</width>
            <height>326</height>
           </rect>
          </property>
@@ -337,7 +337,7 @@ Unless you *really* know what you do, leave this as ISO-8859-1!</string>
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>398</width>
+           <width>301</width>
            <height>326</height>
           </rect>
          </property>
@@ -376,49 +376,51 @@ Unless you *really* know what you do, leave this as ISO-8859-1!</string>
             <property name="checked" >
              <bool>true</bool>
             </property>
+            <layout class="QGridLayout" name="gridLayout" >
+             <item row="0" column="0" >
+              <widget class="QLabel" name="label_2" >
+               <property name="text" >
+                <string>Service:</string>
+               </property>
+              </widget>
+             </item>
+             <item row="0" column="1" >
+              <widget class="QLineEdit" name="autoIdentifyService" >
+               <property name="enabled" >
+                <bool>true</bool>
+               </property>
+               <property name="text" >
+                <string>NickServ</string>
+               </property>
+              </widget>
+             </item>
+             <item row="1" column="0" >
+              <widget class="QLabel" name="label_3" >
+               <property name="enabled" >
+                <bool>true</bool>
+               </property>
+               <property name="text" >
+                <string>Password:</string>
+               </property>
+              </widget>
+             </item>
+             <item row="1" column="1" >
+              <widget class="QLineEdit" name="autoIdentifyPassword" >
+               <property name="enabled" >
+                <bool>true</bool>
+               </property>
+               <property name="echoMode" >
+                <enum>QLineEdit::Password</enum>
+               </property>
+              </widget>
+             </item>
+            </layout>
+            <zorder>autoIdentifyService</zorder>
+            <zorder>autoIdentifyPassword</zorder>
+            <zorder>label_2</zorder>
+            <zorder>label_3</zorder>
            </widget>
           </item>
-          <item>
-           <layout class="QGridLayout" >
-            <item row="0" column="0" >
-             <widget class="QLabel" name="label_2" >
-              <property name="text" >
-               <string>Service:</string>
-              </property>
-             </widget>
-            </item>
-            <item row="0" column="1" >
-             <widget class="QLineEdit" name="autoIdentifyService" >
-              <property name="enabled" >
-               <bool>true</bool>
-              </property>
-              <property name="text" >
-               <string>NickServ</string>
-              </property>
-             </widget>
-            </item>
-            <item row="1" column="0" >
-             <widget class="QLabel" name="label_3" >
-              <property name="enabled" >
-               <bool>true</bool>
-              </property>
-              <property name="text" >
-               <string>Password:</string>
-              </property>
-             </widget>
-            </item>
-            <item row="1" column="1" >
-             <widget class="QLineEdit" name="autoIdentifyPassword" >
-              <property name="enabled" >
-               <bool>true</bool>
-              </property>
-              <property name="echoMode" >
-               <enum>QLineEdit::Password</enum>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </item>
          </layout>
         </widget>
         <widget class="QWidget" name="tab" >
@@ -426,7 +428,7 @@ Unless you *really* know what you do, leave this as ISO-8859-1!</string>
           <rect>
            <x>0</x>
            <y>0</y>
-           <width>398</width>
+           <width>301</width>
            <height>326</height>
           </rect>
          </property>
diff --git a/src/qtui/titlesetter.cpp b/src/qtui/titlesetter.cpp
new file mode 100644 (file)
index 0000000..f48f000
--- /dev/null
@@ -0,0 +1,49 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   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) version 3.                                           *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "titlesetter.h"
+
+#include "abstractitemview.h"
+#include "mainwin.h"
+
+TitleSetter::TitleSetter(MainWin *parent)
+  : AbstractItemView(parent),
+    _mainWin(parent)
+{
+
+}
+
+void TitleSetter::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
+  Q_UNUSED(previous);
+  changeWindowTitle(current.sibling(current.row(), 0).data().toString());
+}
+
+void TitleSetter::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) {
+  QItemSelectionRange changedArea(topLeft, bottomRight);
+  QModelIndex currentTopicIndex = selectionModel()->currentIndex().sibling(selectionModel()->currentIndex().row(), 0);
+  if(changedArea.contains(currentTopicIndex))
+    changeWindowTitle(currentTopicIndex.data().toString());
+};
+
+void TitleSetter::changeWindowTitle(QString title) {
+  QString newTitle = QString("%1 - %2").arg("Quassel IRC").arg(title);
+  _mainWin->setWindowTitle(newTitle);
+  _mainWin->setWindowIconText(newTitle);
+}
diff --git a/src/qtui/titlesetter.h b/src/qtui/titlesetter.h
new file mode 100644 (file)
index 0000000..5fe1aee
--- /dev/null
@@ -0,0 +1,45 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   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) version 3.                                           *
+ *                                                                         *
+ *   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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+
+#ifndef TITLESETTER_H
+#define TITLESETTER_H
+
+#include "abstractitemview.h"
+
+class MainWin;
+
+class TitleSetter : public AbstractItemView {
+  Q_OBJECT
+
+  public:
+    TitleSetter(MainWin *parent);
+
+  protected slots:
+    virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);
+    virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+
+  private:
+    MainWin *_mainWin;
+    void changeWindowTitle(QString title);
+};
+
+
+#endif
index a57069b..78d8bae 100644 (file)
@@ -81,7 +81,7 @@ void BufferView::init() {
 void BufferView::setModel(QAbstractItemModel *model) {
   delete selectionModel();
   if(QTreeView::model()) {
-    disconnect(QTreeView::model(), SIGNAL(layoutChanged()), this, SLOT(updateSelection()));
+    disconnect(QTreeView::model(), SIGNAL(layoutChanged()), this, SLOT(layoutChanged()));
   }
   
   QTreeView::setModel(model);
@@ -96,7 +96,7 @@ void BufferView::setModel(QAbstractItemModel *model) {
   if(!model)
     return;
 
-  connect(model, SIGNAL(layoutChanged()), this, SLOT(updateSelection()));
+  connect(model, SIGNAL(layoutChanged()), this, SLOT(layoutChanged()));
   
   QString sectionName;
   QAction *showSection;
@@ -187,9 +187,10 @@ void BufferView::keyPressEvent(QKeyEvent *event) {
   QTreeView::keyPressEvent(event);
 }
 
-// ensure that newly inserted network nodes are expanded per default
 void BufferView::rowsInserted(const QModelIndex & parent, int start, int end) {
   QTreeView::rowsInserted(parent, start, end);
+
+  // ensure that newly inserted network nodes are expanded per default
   if(parent.data(NetworkModel::ItemTypeRole) != NetworkModel::NetworkItemType)
     return;
   
@@ -200,9 +201,24 @@ void BufferView::rowsInserted(const QModelIndex & parent, int start, int end) {
   }
 }
 
-void BufferView::updateSelection() {
+void BufferView::layoutChanged() {
+  Q_ASSERT(model());
+
+  // expand all active networks
+  QModelIndex networkIdx;
+  for(int row = 0; row < model()->rowCount(); row++) {
+    networkIdx = model()->index(row, 0);
+    update(networkIdx);
+    if(model()->rowCount(networkIdx) > 0 && model()->data(networkIdx, NetworkModel::ItemActiveRole) == true) {
+      expand(networkIdx);
+    } else {
+      collapse(networkIdx);
+    }
+  }
+
+  // update selection to current one
   MappedSelectionModel *mappedSelectionModel = qobject_cast<MappedSelectionModel *>(selectionModel());
-  if(!config())
+  if(!config() || !mappedSelectionModel)
     return;
 
   mappedSelectionModel->mappedSetCurrentIndex(Client::bufferModel()->standardSelectionModel()->currentIndex(), QItemSelectionModel::Current);
index 6485fa5..b42c6c1 100644 (file)
@@ -64,7 +64,7 @@ private slots:
   void joinChannel(const QModelIndex &index);
   void toggleHeader(bool checked);
   void showContextMenu(const QPoint &);
-  void updateSelection();
+  void layoutChanged();
 
 private:
   QPointer<BufferViewConfig> _config;
index 021ed4a..53e17af 100644 (file)
@@ -4,8 +4,8 @@
 { using namespace Global;
 
   quasselVersion = "0.2.0-beta1-pre";
-  quasselDate = "2008-04-18";
-  quasselBuild = 777;
+  quasselDate = "2008-04-21";
+  quasselBuild = 786;
 
   //! Minimum client build number the core needs
   clientBuildNeeded = 731;