Merge branch 'master' of git@git.quassel-irc.org:quassel
authorMarcus Eggenberger <egs@quassel-irc.org>
Wed, 18 Jun 2008 17:01:15 +0000 (19:01 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Wed, 18 Jun 2008 17:01:15 +0000 (19:01 +0200)
src/core/ircserverhandler.cpp
src/core/userinputhandler.cpp
src/uisupport/bufferviewfilter.cpp
src/uisupport/bufferviewfilter.h

index 5034a71..3d7596d 100644 (file)
@@ -433,7 +433,6 @@ void IrcServerHandler::handle005(const QString &prefix, const QList<QByteArray>
   const int numParams = params.size();
   if(numParams < 1) {
     qWarning() << "IrcServerHandler::handle005(): received RPL_ISUPPORT (005) with too few parameters:" << serverDecode(params);
-    return;
   }
 
   QString rpl_isupport_suffix = serverDecode(params.last());
index ee335e6..c42c475 100644 (file)
@@ -193,7 +193,6 @@ void UserInputHandler::handleList(const BufferInfo &bufferInfo, const QString &m
   emit putCmd("LIST", serverEncode(msg.split(' ', QString::SkipEmptyParts)));
 }
 
-
 void UserInputHandler::handleMe(const BufferInfo &bufferInfo, const QString &msg) {
   if(bufferInfo.bufferName().isEmpty()) return; // server buffer
   networkConnection()->ctcpHandler()->query(bufferInfo.bufferName(), "ACTION", msg);
@@ -202,8 +201,14 @@ void UserInputHandler::handleMe(const BufferInfo &bufferInfo, const QString &msg
 
 void UserInputHandler::handleMode(const BufferInfo &bufferInfo, const QString &msg) {
   Q_UNUSED(bufferInfo)
+
+  QStringList params = msg.split(' ', QString::SkipEmptyParts);
+  // if the first argument is neither a channel nor us (user modes are only to oneself) the current buffer is assumed to be the target
+  if(!params.isEmpty() && !network()->isChannelName(params[0]) && !network()->isMyNick(params[0]))
+    params.prepend(bufferInfo.bufferName());
+  
   // TODO handle correct encoding for buffer modes (channelEncode())
-  emit putCmd("MODE", serverEncode(msg.split(' ', QString::SkipEmptyParts)));
+  emit putCmd("MODE", serverEncode(params));
 }
 
 // TODO: show privmsgs
index 0adf8eb..04e3156 100644 (file)
@@ -39,7 +39,8 @@ public:
 *****************************************/
 BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, BufferViewConfig *config)
   : QSortFilterProxyModel(model),
-    _config(0)
+    _config(0),
+    _sortOrder(Qt::AscendingOrder)
 {
   setConfig(config);
   setSourceModel(model);
@@ -125,11 +126,17 @@ bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action
     if(droppedNetworkId == networkId) {
       if(row < 0)
        row = 0;
+
       if(row < rowCount(parent)) {
        BufferId beforeBufferId = parent.child(row, 0).data(NetworkModel::BufferIdRole).value<BufferId>();
        pos = config()->bufferList().indexOf(beforeBufferId);
+       if(_sortOrder == Qt::DescendingOrder)
+         pos++;
       } else {
-       pos = config()->bufferList().count();
+       if(_sortOrder == Qt::AscendingOrder)
+         pos = config()->bufferList().count();
+       else
+         pos = 0;
       }
 
       if(config()->bufferList().contains(bufferId)) {
@@ -147,6 +154,11 @@ bool BufferViewFilter::dropMimeData(const QMimeData *data, Qt::DropAction action
   return true;
 }
 
+void BufferViewFilter::sort(int column, Qt::SortOrder order) {
+  _sortOrder = order;
+  QSortFilterProxyModel::sort(column, order);
+}
+
 void BufferViewFilter::addBuffer(const BufferId &bufferId) const {
   if(!config() || config()->bufferList().contains(bufferId))
     return;
index 128b3e8..56fa974 100644 (file)
@@ -61,6 +61,8 @@ public:
   void setConfig(BufferViewConfig *config);
   inline BufferViewConfig *config() const { return _config; }
 
+  virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+                                                                        
 public slots:
   void checkPreviousCurrentForRemoval(const QModelIndex &current, const QModelIndex &previous);
   void checkItemForRemoval(const QModelIndex &index) { checkItemsForRemoval(index, index); }
@@ -81,6 +83,7 @@ private slots:
     
 private:
   QPointer<BufferViewConfig> _config;
+  Qt::SortOrder _sortOrder;
   
   QColor _FgColorInactiveActivity;
   QColor _FgColorNoActivity;