From 0968d147eef44e67582e82b7cec23a9843a1663c Mon Sep 17 00:00:00 2001 From: "cavernxxx@gmail.com" Date: Wed, 9 Sep 2009 23:38:11 +0000 Subject: [PATCH] Fixed Issue 124 Though history support is quite basic now. Removed setConfugiration(QUrl) methods and accompanied stuff - deprecated by ServerProfilesModel. git-svn-id: http://qtlobby.googlecode.com/svn/trunk@548 5a83989a-60d1-11de-a6a3-193033c112f2 --- CMakeLists.txt | 4 +- buildbot/src/build.py | 2 +- src/AbstractChannel.cpp | 72 ++++++++++++++++++++++-------------- src/AbstractChannel.h | 10 ++++- src/AbstractLobbyTab.cpp | 3 +- src/BattleHostingDialog.cpp | 7 +--- src/BattleHostingDialog.h | 2 - src/Battles.cpp | 43 ++++++++++------------ src/Battles.h | 4 -- src/CMakeLists.txt | 5 +++ src/ConnectionWidget.cpp | 8 +--- src/ConnectionWidget.h | 2 - src/History.cpp | 54 +++++++++++++++++++++++++++ src/History.h | 29 +++++++++++++++ src/HistoryDialog.cpp | 61 +++++++++++++++++++++++++++++++ src/HistoryDialog.h | 32 ++++++++++++++++ src/MainWindow.cpp | 39 ++++++++++---------- src/MainWindow.h | 4 +- src/MapInfoLoader.cpp | 6 +-- src/PathManager.cpp | 26 +++++++++---- src/PathManager.h | 2 + src/PrivateChannel.cpp | 4 +- src/ServerContextState.cpp | 11 ++---- src/ServerContextState.h | 3 -- src/ServerProfilesModel.cpp | 12 ++++++ src/ServerProfilesModel.h | 2 + src/Users.cpp | 24 +++++------- src/Users.h | 4 -- ui/HistoryDialog.ui | 73 +++++++++++++++++++++++++++++++++++++ ui/MainWidget.ui | 23 ++++++++++++ 30 files changed, 433 insertions(+), 138 deletions(-) create mode 100644 src/History.cpp create mode 100644 src/History.h create mode 100644 src/HistoryDialog.cpp create mode 100644 src/HistoryDialog.h create mode 100644 ui/HistoryDialog.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 1eff50a..4e754d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,10 +33,10 @@ set(QT_USE_QTXML true) if(WIN32 OR BUILDBOT) option(PURE_WINAPI_UNITSYNC_LOADER "Use pure Win API unitsync loader(helps against some loading bugs)" ON) mark_as_advanced(PURE_WINAPI_UNITSYNC_LOADER) - find_package(Qt4 COMPONENTS QtCore QtGui QtScript QtNetwork QtOpenGL QtXml REQUIRED) # -QtDbus + find_package(Qt4 COMPONENTS QtCore QtGui QtScript QtNetwork QtOpenGL QtXml QtSql REQUIRED) # -QtDbus else(WIN32 OR BUILDBOT) set(QT_USE_QTDBUS true) - find_package(Qt4 COMPONENTS QtCore QtGui QtDbus QtScript QtNetwork QtOpenGL QtXml REQUIRED) + find_package(Qt4 COMPONENTS QtCore QtGui QtDbus QtScript QtNetwork QtOpenGL QtXml QtSql REQUIRED) endif(WIN32 OR BUILDBOT) find_package(QScintilla REQUIRED) diff --git a/buildbot/src/build.py b/buildbot/src/build.py index 2a46732..5997cb7 100644 --- a/buildbot/src/build.py +++ b/buildbot/src/build.py @@ -61,7 +61,7 @@ def run(self): self.runCommand("rm -rf *") self.runCommand("touch ../src/config.h") self.runCommand("rm -f cbuild/src/qtlobby.*") - self.runCommand("cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-mingw.cmake -DBUILDBOT=ON -DTRANSLATIONS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo ..") + self.runCommand("cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-mingw.cmake -DBUILDBOT=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..") self.runCommand("make") os.chdir("src") self.runCommand("objcopy --only-keep-debug qtlobby.exe qtlobby.dbg") diff --git a/src/AbstractChannel.cpp b/src/AbstractChannel.cpp index f2a8477..478f0bf 100644 --- a/src/AbstractChannel.cpp +++ b/src/AbstractChannel.cpp @@ -2,8 +2,7 @@ // QtLobby released under the GPLv3, see COPYING for details. #include "AbstractChannel.h" #include "PathManager.h" - -QString AbstractChannel::currentUsername; +#include "ServerProfilesModel.h" AbstractChannel::AbstractChannel( QString name, QObject * parent ) : AbstractLobbyTab( parent ) { setObjectName( name ); @@ -11,6 +10,7 @@ AbstractChannel::AbstractChannel( QString name, QObject * parent ) : AbstractLob inactiveIcon = QIcon( P("icons/channel_unread.xpm") ); activeTextColor = QColor("black"); inactiveTextColor = QColor("green"); + historyMode = false; } AbstractChannel::~AbstractChannel() {} @@ -19,12 +19,7 @@ void AbstractChannel::setupUi( QWidget * channelTabWidget ) { channelTabWidget->setObjectName( QString::fromUtf8( "channelTabWidget" ) + objectName() ); channelTextBrowser = new ChannelTextBrowser( channelTabWidget ); channelTextBrowser->setObjectName( "channelTextBrowser" + objectName() ); - channelTextBrowser->setOpenLinks(false); - channelTextBrowser->setReadOnly( true ); - QTextDocument * channelTextDocument = new QTextDocument( channelTextBrowser ); - //after exeeding the 500 blocks the first block will be removed - channelTextDocument->setMaximumBlockCount( 500 ); - channelTextBrowser->setDocument( channelTextDocument ); + setChannelBrowser(channelTextBrowser); gridLayout = new QGridLayout( channelTabWidget ); gridLayout->setContentsMargins(0,0,0,0); gridLayout->setObjectName( QString::fromUtf8( "channelGridLayout" ) + objectName() ); @@ -73,17 +68,17 @@ bool AbstractChannel::executeChannelInput( QString input ) { ret.name = "CLIENTMSG"; QString row( "%1%2" ); ret.attributes << objectName() << tr("Chat Help").append(" %1
" ).arg( - row.arg( "/help, /h", tr( "Display this help" ) ) + - row.arg( "/channels, /list", tr( "Display channel list" ) ) + - row.arg( "/join, /j <channel>", tr( "Join channel" ) ) + - row.arg( "/j <channel> <password>", tr( "Join password protected channel" ) ) + - row.arg( "/j <channel1> <password1>, <channel2> ... ", tr( "Join multiple channels" ) ) + - row.arg( "/me <text>", tr( "Say highlighted" ) ) + - row.arg( "/sayver", tr( "Say /me is using QtLobby vXXX revYYY" ) ) + - row.arg( "/slap <user>", tr( "Say the mIRC slap sentence" ) ) + - row.arg( "/query, /msg <user>", tr( "Open private chat" ) ) + - row.arg( "/leave, /wc", tr( "Leave the channel" ) ) - ); + row.arg( "/help, /h", tr( "Display this help" ) ) + + row.arg( "/channels, /list", tr( "Display channel list" ) ) + + row.arg( "/join, /j <channel>", tr( "Join channel" ) ) + + row.arg( "/j <channel> <password>", tr( "Join password protected channel" ) ) + + row.arg( "/j <channel1> <password1>, <channel2> ... ", tr( "Join multiple channels" ) ) + + row.arg( "/me <text>", tr( "Say highlighted" ) ) + + row.arg( "/sayver", tr( "Say /me is using QtLobby vXXX revYYY" ) ) + + row.arg( "/slap <user>", tr( "Say the mIRC slap sentence" ) ) + + row.arg( "/query, /msg <user>", tr( "Open private chat" ) ) + + row.arg( "/leave, /wc", tr( "Leave the channel" ) ) + ); receiveCommand( ret ); return true; } else if ( QString( "/ingame" ).split( "," ).contains( firstWord, Qt::CaseInsensitive ) ) { @@ -96,7 +91,12 @@ bool AbstractChannel::executeChannelInput( QString input ) { } void AbstractChannel::insertLine( QString line ) { - QString timeString = QString( "%1 " ).arg( QTime().currentTime().toString( "[hh:mm:ss]" ) ); + QTime t; + if(historyMode) + t = historyDateTime.time(); + else + t = QTime::currentTime(); + QString timeString = QString( "%1 " ).arg( t.toString( "[hh:mm:ss]" ) ); bool scrollToMaximum = channelTextBrowser->verticalScrollBar()->value() == channelTextBrowser->verticalScrollBar()->maximum(); QTextCursor c = channelTextBrowser->textCursor(); //go to end of document @@ -116,13 +116,13 @@ void AbstractChannel::insertLine( QString line ) { QString AbstractChannel::makeHtml( QString in ) { QString ret = in; ret.replace( "\n", "
" ); + if(historyMode) { + ret.prepend(""); + ret.append(""); + } return ret.prepend( "

" ).append( "

" ); } -void AbstractChannel::setCurrentUsername(QString user) { - currentUsername = user; -} - /* 2 \b Ctrl+B Bold (toggle) 15 \o Ctrl+O Normal (turn off bold, italic, underline, fixed pitch, reverse, and colors) @@ -309,15 +309,16 @@ QString AbstractChannel::highlightUserName( QString input ) { if( !Settings::Instance()->value("Chat/highlightUserName").toBool() ) return input; // highlight currentUsername - QString pattern = currentUsername; + QString username = ServerProfilesModel::getInstance()->getActiveProfile().userName(); + QString pattern = username; pattern.replace("[", "\\[").replace("]", "\\]"); pattern += "(?!>)"; - input.replace(QRegExp(pattern), ""+currentUsername+""); + input.replace(QRegExp(pattern), ""+username+""); return input; } QString AbstractChannel::userNameLink( const QString userName ) { - if( userName == currentUsername ) + if( userName == ServerProfilesModel::getInstance()->getActiveProfile().userName() ) return userName; QUrl url("qtlobby://query"); url.addQueryItem("username",userName); @@ -332,3 +333,20 @@ void AbstractChannel::anchorClicked(QUrl url) { QDesktopServices::openUrl(url); } } + +void AbstractChannel::setChannelBrowser(ChannelTextBrowser* b) { + channelTextBrowser = b; + channelTextBrowser->setOpenLinks(false); + channelTextBrowser->setReadOnly( true ); + QTextDocument * channelTextDocument = new QTextDocument( channelTextBrowser ); + channelTextBrowser->setDocument( channelTextDocument ); +} + +void AbstractChannel::historyMessage( QDateTime time, QString message ) { + historyDateTime = time; + receiveCommand(Command(message)); +} + +void AbstractChannel::setHistoryMode(bool b) { + historyMode = b; +} diff --git a/src/AbstractChannel.h b/src/AbstractChannel.h index 17b20c0..e554ecb 100644 --- a/src/AbstractChannel.h +++ b/src/AbstractChannel.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -18,11 +19,14 @@ class AbstractChannel : public AbstractLobbyTab { public: AbstractChannel( QString name, QObject * parent = 0 ); virtual ~AbstractChannel(); - static void setCurrentUsername(QString user); + void setChannelBrowser(ChannelTextBrowser* b); + void setHistoryMode(bool b); public slots: virtual void receiveInput( QString input ) = 0; virtual void receiveCommand( Command command ) = 0; + virtual void historyMessage( QDateTime time, QString message ); + protected: void setActive( bool isActive ); virtual void setupUi( QWidget * tab ); @@ -40,8 +44,10 @@ public slots: QIcon inactiveIcon; QColor activeTextColor; QColor inactiveTextColor; - static QString currentUsername; QString userNameLink( const QString userName ); + + bool historyMode; + QDateTime historyDateTime; protected slots: void anchorClicked(QUrl url); }; diff --git a/src/AbstractLobbyTab.cpp b/src/AbstractLobbyTab.cpp index 78da5d3..59716b8 100644 --- a/src/AbstractLobbyTab.cpp +++ b/src/AbstractLobbyTab.cpp @@ -8,12 +8,13 @@ AbstractLobbyTab::AbstractLobbyTab( QObject * parent ) { isActive = false; currentWidget = 0; currentTabIndex = -1; + userNameCountryCodeMap = 0; } AbstractLobbyTab::~AbstractLobbyTab() {} QString AbstractLobbyTab::flag( const QString userName ) { QString flag = " "; - if( Settings::Instance()->value("Chat/showFlags").toBool() ) + if( Settings::Instance()->value("Chat/showFlags").toBool() && userNameCountryCodeMap ) if ( userNameCountryCodeMap->contains( userName ) ) return flag.arg( userNameCountryCodeMap->value( userName ) ); return ""; diff --git a/src/BattleHostingDialog.cpp b/src/BattleHostingDialog.cpp index d51136b..b22be5d 100644 --- a/src/BattleHostingDialog.cpp +++ b/src/BattleHostingDialog.cpp @@ -3,6 +3,7 @@ #include "BattleHostingDialog.h" #include "ui_BattleHostingDialog.h" #include "UnitSyncLib.h" +#include "ServerProfilesModel.h" BattleHostingDialog::BattleHostingDialog(QProcess* spring, CommandAssigner* assigner, LobbyTabs* lobbyTabs, QWidget *parent) : QDialog(parent), @@ -39,7 +40,7 @@ void BattleHostingDialog::on_buttonBox_accepted() { QMessageBox::critical(this, tr("Error"), tr("You have a battle running!\nClose it first!")); return; } - m_battleHost = new BattleHost(m_currentUsername, this); + m_battleHost = new BattleHost(ServerProfilesModel::getInstance()->getActiveProfile().userName(), this); QString passwd = m_ui->passwordLineEdit->text(); m_battleHost->setHostingParams(0, 0, @@ -74,10 +75,6 @@ void BattleHostingDialog::onClosed() { m_battleHost = 0; } -void BattleHostingDialog::setCurrentUsername(QString username) { - m_currentUsername = username; -} - void BattleHostingDialog::onReboot() { UnitSyncLib* unitSyncLib = UnitSyncLib::getInstance(); m_ui->modComboBox->clear(); diff --git a/src/BattleHostingDialog.h b/src/BattleHostingDialog.h index 919b173..960cd6f 100644 --- a/src/BattleHostingDialog.h +++ b/src/BattleHostingDialog.h @@ -18,7 +18,6 @@ class BattleHostingDialog : public QDialog { public: explicit BattleHostingDialog(QProcess* spring, CommandAssigner* assigner, LobbyTabs* lobbyTabs, QWidget *parent = 0); virtual ~BattleHostingDialog(); - void setCurrentUsername(QString username); protected: virtual void changeEvent(QEvent *e); @@ -33,7 +32,6 @@ private slots: BattleHost* m_battleHost; CommandAssigner* m_assigner; LobbyTabs* m_tabs; - QString m_currentUsername; QProcess* m_spring; }; diff --git a/src/Battles.cpp b/src/Battles.cpp index 3ec1251..64c2f0e 100644 --- a/src/Battles.cpp +++ b/src/Battles.cpp @@ -1,6 +1,7 @@ // $Id$ // QtLobby released under the GPLv3, see COPYING for details. #include "Battles.h" +#include "ServerProfilesModel.h" #include #include #include @@ -109,6 +110,7 @@ Battles::~Battles() {} void Battles::receiveCommand( Command command ) { // qDebug()<< "command: " << command.toQString(); + QUrl url = ServerProfilesModel::getInstance()->getActiveProfile(); command.name = command.name.toUpper(); if ( command.name == "CLIENTSTATUS" ) { User u = users->getUser( command.attributes[0] ); @@ -190,7 +192,7 @@ void Battles::receiveCommand( Command command ) { users->onMyBattleStateChanged( u ); } } else if ( command.name == "SETSCRIPTTAGS" ) { - int bi = users->getUser( username ).joinedBattleId; + int bi = users->getUser( url.userName() ).joinedBattleId; if( !battleManager->isBattleId( bi ) ) return; Battle b = battleManager->getBattle( bi ); @@ -201,7 +203,7 @@ void Battles::receiveCommand( Command command ) { } battleManager->modBattle( b ); } else if ( command.name == "REMOVESCRIPTTAGS" ) { - int bi = users->getUser( username ).joinedBattleId; + int bi = users->getUser( url.userName() ).joinedBattleId; if( !battleManager->isBattleId( bi ) ) return; Battle b = battleManager->getBattle( bi ); @@ -213,7 +215,7 @@ void Battles::receiveCommand( Command command ) { } battleManager->modBattle( b ); } else if ( command.name == "ADDSTARTRECT" ) { // allyno left top right bottom - int bi = users->getUser( username ).joinedBattleId; + int bi = users->getUser( url.userName() ).joinedBattleId; if( !battleManager->isBattleId( bi ) ) return; Battle b = battleManager->getBattle( bi ); @@ -231,7 +233,7 @@ void Battles::receiveCommand( Command command ) { emit addStartRect(command.attributes[0].toInt(), r); battleManager->modBattle( b ); } else if ( command.name == "REMOVESTARTRECT" ) { // allyno - int bi = users->getUser( username ).joinedBattleId; + int bi = users->getUser( url.userName() ).joinedBattleId; if( !battleManager->isBattleId( bi ) ) return; Battle b = battleManager->getBattle( bi ); @@ -263,10 +265,6 @@ void Battles::receiveCommand( Command command ) { } } -void Battles::setConfiguration( QUrl url ) { - this->url = url; -} - void Battles::setRegExp( QString regExp ) { battleManager->proxyModel()->setFilterString(regExp); //battleManager->proxyModel()->setFilterKeyColumn( -1 ); @@ -277,7 +275,7 @@ void Battles::doubleClicked( const QModelIndex & index ) { Battle b = battleManager->model()-> data( battleManager->proxyModel()->mapToSource( index ), Qt::UserRole ).value(); if ( !b.isLocked ) { - User me = this->users->getUser( url.userName() ); + User me = this->users->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ); if ( me.joinedBattleId == b.id ) // don't rejoin same return; if ( b.isPasswordProtected ) { @@ -294,7 +292,7 @@ void Battles::joinBattleCommand( unsigned int id, QString password, bool closeFi if ( closeFirst ) { emit closeBattleChannel(); } else { - User me = this->users->getUser( url.userName() ); + User me = this->users->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ); if ( me.joinedBattleId >= 0 ) { // in battle if ( !Settings::Instance()->value( "Battle/autoCloseFirst", false ).toBool() ) { battleCloseFirstWidget->setPassword( password ); @@ -338,10 +336,6 @@ void Battles::setUsers( Users* users ) { battleManager->setUsers(users); } -void Battles::setCurrentUsername(QString a_username) { - username = a_username; -} - void Battles::startGame( Battle b, bool host ) { QString springDir = settings->value("spring_user_dir").toString(); QFile scriptFile( springDir + "/script_qtlobby.txt" ); @@ -370,7 +364,7 @@ QString Battles::generateScript( Battle b, bool host ) { int numTeams = 0, numAllies = 0, myPlayerNum = -1; for ( int i = 0; i < battleUsers.size(); ++i ) { User u = battleUsers[i]; - if ( u.name == url.userName() ) + if ( u.name == ServerProfilesModel::getInstance()->getActiveProfile().userName() ) myPlayerNum = i; if ( !u.battleState.isPlayer() ) continue; @@ -410,10 +404,10 @@ QString Battles::generateScript( Battle b, bool host ) { gameOptions[k] = QString::number( b.options[k].toFloat() ); } gameOptions["HostPort"] = QString::number(m_portOverride > 0 ? m_portOverride : b.port ); - gameOptions["HostIP"] = b.founder == url.userName() ? QString( "localhost" ) : b.ip; + gameOptions["HostIP"] = b.founder == ServerProfilesModel::getInstance()->getActiveProfile().userName() ? QString( "localhost" ) : b.ip; gameOptions["IsHost"] = host ? "1" : "0"; gameOptions["MyPlayerNum"] = QString::number( myPlayerNum ); - gameOptions["MyPlayerName"] = username; + gameOptions["MyPlayerName"] = ServerProfilesModel::getInstance()->getActiveProfile().userName(); gameOptions["NumPlayers"] = QString::number( b.playerCount ); gameOptions["NumTeams"] = QString::number( numTeams + numBots ); gameOptions["NumAllyTeams"] = QString::number( numAllies ); @@ -524,21 +518,24 @@ QString Battles::generateScript( Battle b, bool host ) { * returns the sync status for map checksums */ int Battles::resyncStatus() { - int battleId = users->getUser( url.userName() ).joinedBattleId; - + int battleId = users->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ).joinedBattleId; if ( !battleManager->isBattleId( battleId ) ) { // set battle status to unsync // popup messagebox with error, that this should not happen - qDebug() << __FILE__ << __LINE__<< " error: should I resync for a none existing battle?!"; + qDebug() << __FILE__ << __LINE__<< " error: should I resync for a none existing battle(id: " << battleId << "?!"; return 0; } Battle b = battleManager->getBattle( battleId ); QString modName = b.modName; - if ( UnitSyncLib::getInstance()->mapChecksum( b.mapName ) != ( unsigned int ) b.mapHash ) + if ( UnitSyncLib::getInstance()->mapChecksum( b.mapName ) != ( unsigned int ) b.mapHash ) { + qDebug() << "Map checksum is wrong"; return 2; // 2 = not sync - if (UnitSyncLib::getInstance()->modIndex(modName) < 0) + } + if (UnitSyncLib::getInstance()->modIndex(modName) < 0) { + qDebug() << "Mod not found"; return 2; // 2 = not sync + } return 1; // 1 = sync is 'in sync' } @@ -597,7 +594,7 @@ void Battles::setFilterWithoutFriendsSlot( bool state ) { void Battles::onReboot() { qDebug() << "Resyncing"; - User u = users->getUser( url.userName() ); + User u = users->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ); u.battleState.setSyncState(resyncStatus()); users->onMyBattleStateChanged( u ); } diff --git a/src/Battles.h b/src/Battles.h index d26c0df..41ce691 100644 --- a/src/Battles.h +++ b/src/Battles.h @@ -47,9 +47,7 @@ class Battles : public QTreeView { public slots: void setRegExp( QString regExp ); void receiveCommand( Command command ); - void setConfiguration( QUrl url ); void joinBattleCommand( unsigned int id, QString password, bool firstClose ); - void setCurrentUsername( QString username ); void invalidateModel(); void connectionStateChanged( ConnectionState state ); void onJoin(); @@ -75,9 +73,7 @@ protected slots: void retranslateUi(); QString currentTabType; QString currentTabName; - QString username; Users* users; - QUrl url; BattlePasswordWidget* battlePasswordWidget; QSettings* settings; int battleCount; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index edf8929..9b4aed6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,6 +78,8 @@ Users.cpp UsersTreeView.cpp UserTreeModel.cpp sqadsprototypes.cpp +History.cpp +HistoryDialog.cpp ) set(qtlobby_SRCS_H @@ -155,6 +157,8 @@ Users.h UsersTreeView.h UserTreeModel.h sqadsprototypes.h +History.h +HistoryDialog.h ) if(UNIX) @@ -185,6 +189,7 @@ set( qtlobby_UIS ../ui/StylesheetDialog.ui ../ui/ToolBarWidget.ui ../ui/UserGroupsDialog.ui +../ui/HistoryDialog.ui ) QT4_WRAP_UI(qtlobby_UIS_H ${qtlobby_UIS}) diff --git a/src/ConnectionWidget.cpp b/src/ConnectionWidget.cpp index d1a5783..6759942 100644 --- a/src/ConnectionWidget.cpp +++ b/src/ConnectionWidget.cpp @@ -119,6 +119,7 @@ void ConnectionWidget::establishConnection() { tr("You have to add a profile first before you can connect to a server.") ); return; } + ServerProfilesModel::getInstance()->setActiveProfile(index); QUrl url = ServerProfilesModel::getInstance()->data(index, Qt::UserRole).toUrl(); if ( !rememberPassCheckBox->isChecked() ) { url.setPassword(""); @@ -141,9 +142,7 @@ void ConnectionWidget::establishConnection() { ServerProfilesModel::getInstance()->modifyProfile( index, url ); } - emit emitConfiguration( url ); emit establishConnection_(); - emit usernameChanged(url.userName()); } void ConnectionWidget::simpleViewChanged() { @@ -175,9 +174,8 @@ void ConnectionWidget::establishSimpleConnection() { simpleUrl.setPassword( simplePasswdEdit->text() ); simpleUrl.setScheme("tas"); - emit emitConfiguration( simpleUrl ); + ServerProfilesModel::getInstance()->setActiveProfile(simpleUrl); emit establishConnection_(); - emit usernameChanged(simpleUrl.userName()); if(!simpleRememberPasswdChechbox->isChecked()) simpleUrl.setPassword(QString::null); settings->setValue("simpleLogin", simpleUrl.toString()); @@ -298,7 +296,6 @@ void ConnectionWidget::renameLoginName() { if ( newUsername == "" ) return; serverContextState->sendMessage( QString( "RENAMEACCOUNT %1" ).arg( newUsername ) ) ; - emit usernameChanged(newUsername); } void ConnectionWidget::renameLoginNameFeedbackSuccess( QString newName ) { @@ -374,7 +371,6 @@ void ConnectionWidget::registerNewAccount() { this, SLOT( registrationSuccessFeedback(QString)) ); configuration.setHost(newServerLineEdit->text()); configuration.setPort(newPortSpinBox->value()); - registrationServerContextState->setConfiguration(configuration); registrationServerContextState->registerNewAccount(username, passwordTry1lineEdit->text()); configuration.setUserName(username); configuration.setPassword(passwordTry1lineEdit->text()); diff --git a/src/ConnectionWidget.h b/src/ConnectionWidget.h index ff43e8e..a1e356e 100644 --- a/src/ConnectionWidget.h +++ b/src/ConnectionWidget.h @@ -30,9 +30,7 @@ class ConnectionWidget : public QDialog, public Ui::ConnectionWidget { ConnectionWidget( ServerContextState*, QWidget *parent = 0 ); ~ConnectionWidget(); signals: - void emitConfiguration( QUrl ); void establishConnection_(); - void usernameChanged(QString username); public slots: void show_if_wanted(); void logWrite( QString ); diff --git a/src/History.cpp b/src/History.cpp new file mode 100644 index 0000000..a90cc86 --- /dev/null +++ b/src/History.cpp @@ -0,0 +1,54 @@ +#include "History.h" +#include "PathManager.h" + +History::History(QObject* parent) : QObject(parent) { + m_initialized = false; + m_filter << "SAYPRIVATE" + << "SAIDPRIVATE" + //<< "SAIDBATTLE" + //<< "SAIDBATTLEEX" + << "SAID" + << "SAIDEX" + //<< "JOINEDBATTLE" + //<< "LEFTBATTLE" + << "JOINED" + << "LEFT" + ; + initialize(); +} + +void History::initialize() { + if(m_initialized) return; + if(!PathManager::getInstance()->isOverlayValid()) return; + m_db = QSqlDatabase::addDatabase("QSQLITE"); + m_db.setDatabaseName(PathManager::getInstance()->resolveOverlayPath("history.sqlite")); + m_initialized = m_db.open(); + if(!m_initialized) return; + QSqlQuery q; + q.exec("create table history(timestamp integer, command text)"); + qDebug() << q.lastError().text(); + m_insertQuery = QSqlQuery(); + m_fetchQuery = QSqlQuery(); + m_insertQuery.prepare("insert into history values(?, ?)"); + m_fetchQuery.prepare("select * from history where timestamp>=? and timestamp<=?"); +} + +void History::receiveMessage(QString message) { + initialize(); + if(!m_initialized) return; + if(!m_filter.contains(message.split(" ").takeFirst())) return; + m_insertQuery.bindValue(0, QDateTime::currentDateTime().toTime_t()); + m_insertQuery.bindValue(1, message); + m_insertQuery.exec(); +} + +void History::play(QDate from, QDate to) { + initialize(); + if(!m_initialized) return; + m_fetchQuery.bindValue(0, QDateTime(from).toTime_t()); + m_fetchQuery.bindValue(1, QDateTime(to).toTime_t()); + m_fetchQuery.exec(); + while(m_fetchQuery.next()) { + emit historyMessage(QDateTime::fromTime_t(m_fetchQuery.value(0).toUInt()), m_fetchQuery.value(1).toString()); + } +} diff --git a/src/History.h b/src/History.h new file mode 100644 index 0000000..aae7f6a --- /dev/null +++ b/src/History.h @@ -0,0 +1,29 @@ +#ifndef HISTORY_H +#define HISTORY_H + +#include +#include +#include +#include "Singleton.h" + +class History : public QObject, public Singleton { + Q_OBJECT + friend class Singleton; +public: + void play(QDate from, QDate to); +public slots: + void receiveMessage(QString message); +signals: + void historyMessage(QDateTime timestamp, QString message); +private: + QSqlDatabase m_db; + QSqlQuery m_insertQuery; + QSqlQuery m_fetchQuery; + bool m_initialized; + QSet m_filter; + + History(QObject* parent = 0); + void initialize(); +}; + +#endif // HISTORY_H diff --git a/src/HistoryDialog.cpp b/src/HistoryDialog.cpp new file mode 100644 index 0000000..e46b5a5 --- /dev/null +++ b/src/HistoryDialog.cpp @@ -0,0 +1,61 @@ +#include "HistoryDialog.h" +#include "ui_HistoryDialog.h" +#include "Channel.h" +#include "PrivateChannel.h" +#include "History.h" + +HistoryDialog::HistoryDialog(QWidget *parent) : + QDialog(parent), + m_ui(new Ui::HistoryDialog) { + m_ui->setupUi(this); + m_ui->textBrowser->setContextMenuPolicy(Qt::DefaultContextMenu); + m_ui->fromDateEdit->setDate(QDate::currentDate()); + m_ui->toDateEdit->setDate(QDate::currentDate().addDays(1)); + m_channel = 0; +} + +HistoryDialog::~HistoryDialog() { + delete m_ui; +} + +void HistoryDialog::changeEvent(QEvent *e) { + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + m_ui->retranslateUi(this); + break; + default: + break; + } +} + +void HistoryDialog::replayHistory() { + QString type = m_ui->typeComboBox->currentText(); + if(m_channel) delete m_channel; + if(type == "Channel") { + m_channel = new Channel(m_ui->nameLineEdit->text(), this); + } else if(type == "Private") { + m_channel = new PrivateChannel(m_ui->nameLineEdit->text(), this); + } + m_channel->setChannelBrowser(m_ui->textBrowser); + m_channel->setHistoryMode(true); + connect(History::getInstance(), SIGNAL(historyMessage(QDateTime, QString)), + m_channel, SLOT(historyMessage(QDateTime,QString))); + History::getInstance()->play(m_ui->fromDateEdit->date(), m_ui->toDateEdit->date()); +} + +void HistoryDialog::on_typeComboBox_activated(QString type) { + replayHistory(); +} + +void HistoryDialog::on_nameLineEdit_editingFinished(){ + replayHistory(); +} + +void HistoryDialog::on_fromDateEdit_editingFinished() { + replayHistory(); +} + +void HistoryDialog::on_toDateEdit_editingFinished() { + replayHistory(); +} diff --git a/src/HistoryDialog.h b/src/HistoryDialog.h new file mode 100644 index 0000000..3bda1c1 --- /dev/null +++ b/src/HistoryDialog.h @@ -0,0 +1,32 @@ +#ifndef HISTORYDIALOG_H +#define HISTORYDIALOG_H + +#include +#include "AbstractChannel.h" + +namespace Ui { + class HistoryDialog; +} + +class HistoryDialog : public QDialog { + Q_OBJECT +public: + explicit HistoryDialog(QWidget *parent = 0); + virtual ~HistoryDialog(); + +protected: + virtual void changeEvent(QEvent *e); + +private: + void replayHistory(); + Ui::HistoryDialog *m_ui; + AbstractChannel* m_channel; + +private slots: + void on_toDateEdit_editingFinished(); + void on_fromDateEdit_editingFinished(); + void on_nameLineEdit_editingFinished(); + void on_typeComboBox_activated(QString ); +}; + +#endif // HISTORYDIALOG_H diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index b40612d..544be44 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -3,6 +3,8 @@ #include "MainWindow.h" #include "ToolBarWidget.h" #include "PathManager.h" +#include "ServerProfilesModel.h" +#include "History.h" #include #include @@ -19,9 +21,11 @@ MainWindow::MainWindow( QWidget* parent ) : QMainWindow( parent ) { if ( settings->value("unitsync").toString().isEmpty() ) preference->exec(); QDir overlay(settings->value("spring_user_dir").toString()); - overlay.mkdir("qtlobby"); - overlay.cd("qtlobby"); - PathManager::getInstance()->setOverlayPath(overlay.absolutePath()); + if(overlay.exists()) { + overlay.mkdir("qtlobby"); + overlay.cd("qtlobby"); + PathManager::getInstance()->setOverlayPath(overlay.absolutePath()); + } setupUi( this ); setupIcons(); preference->onResetFormToSettings(); @@ -44,6 +48,8 @@ MainWindow::MainWindow( QWidget* parent ) : QMainWindow( parent ) { battleHostingDialog->setWindowFlags(Qt::Window); downloadsDialog = new DownloadsDialog(this); downloadsDialog->setWindowFlags(Qt::Window); + historyDialog = new HistoryDialog(this); + historyDialog->setWindowFlags(Qt::Window); scriptingEngine.globalObject().setProperty("battles", scriptingEngine.newQObject(battles)); scriptingEngine.globalObject().setProperty("users", scriptingEngine.newQObject(users)); @@ -77,6 +83,8 @@ MainWindow::MainWindow( QWidget* parent ) : QMainWindow( parent ) { // serverContextState -> QString -> commandAssigner connect( serverContextState, SIGNAL( incommingMessage( QString ) ), commandAssigner, SLOT( receiveMessage( QString ) ) ); + /*connect( serverContextState, SIGNAL( incommingMessage( QString ) ), + History::getInstance(), SLOT( receiveMessage( QString ) ) );*/ // commandAssigner -> Command -> serverContextState connect( commandAssigner, SIGNAL( serverContextStateCommand( Command ) ), serverContextState, SLOT( receiveCommand( Command ) ) ); @@ -117,18 +125,6 @@ MainWindow::MainWindow( QWidget* parent ) : QMainWindow( parent ) { connect( serverContextState, SIGNAL( connectionStateChanged( ConnectionState ) ), this, SLOT( connectionStatusChanged( ConnectionState ) ) ); - // setting the configuration - connect( connectionWidget, SIGNAL( emitConfiguration( QUrl ) ), - users, SLOT( setConfiguration( QUrl ) ) ); - connect( connectionWidget, SIGNAL( emitConfiguration( QUrl ) ), - battles, SLOT( setConfiguration( QUrl ) ) ); - connect( connectionWidget, SIGNAL( emitConfiguration( QUrl ) ), - serverContextState, SLOT( setConfiguration( QUrl ) ) ); - connect( connectionWidget, SIGNAL( usernameChanged(QString ) ), - battles, SLOT( setCurrentUsername( QString ) ) ); - connect( connectionWidget, SIGNAL( usernameChanged(QString ) ), - this, SLOT( setCurrentUsername( QString ) ) ); - // disconnect connect( action_Disconnect, SIGNAL( triggered() ), serverContextState, SLOT( forceDisconnect() ) ); @@ -443,9 +439,10 @@ void MainWindow::showGroupsDialog() { userGroupsDialog->raise(); } -void MainWindow::setCurrentUsername( QString username ) { - AbstractChannel::setCurrentUsername(username); - battleHostingDialog->setCurrentUsername(username); +void MainWindow::showHistoryDialog() { + historyDialog->show(); + historyDialog->activateWindow(); + historyDialog->raise(); } void MainWindow::onChangedToBattleTab() { @@ -550,16 +547,18 @@ void MainWindow::onTeamPlayerSpecCountChanged(QString ratio) { } else { usersInCurrentChannel->setText(ratio); usersInCurrentChannel->setToolTip(tr("# Players + # Specs (# 1st Ally : # 2nd Ally :...)")); + QUrl url = ServerProfilesModel::getInstance()->getActiveProfile(); availableSlots->setText( tr("free slot(s): %1") .arg(QString::number(battles->battleManager->getBattle(users->getUser( - users->getCurrentUsername()).joinedBattleId).maxPlayers + url.userName()).joinedBattleId).maxPlayers - users->usersInChanCount()))); availableSlots->setToolTip( tr("# free slots in the current battle")); } } void MainWindow::on_hostPushButton_clicked( bool closeFirst ) { - User me = users->getUser( users->getCurrentUsername() ); + QUrl url = ServerProfilesModel::getInstance()->getActiveProfile(); + User me = users->getUser( url.userName() ); if ( closeFirst ) { lobbyTabs->onCloseBattleChannel(); } else if ( me.joinedBattleId >= 0 ) { // in battle diff --git a/src/MainWindow.h b/src/MainWindow.h index 34d13ba..9bd041e 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -29,6 +29,7 @@ #include "ScriptingDialog.h" #include "BattleHost.h" #include "BattleHostingDialog.h" +#include "HistoryDialog.h" #include "DownloadsDialog.h" #include "UserMenuBuilder.h" #include "Notification.h" @@ -70,6 +71,7 @@ class MainWindow : public QMainWindow, private Ui::MainWindow { ScriptingDialog* scriptingDialog; BattleHostingDialog *battleHostingDialog; DownloadsDialog* downloadsDialog; + HistoryDialog* historyDialog; QTabBar* tabBar; QToolButton* newTabButton; @@ -108,12 +110,12 @@ private slots: void toggleShowHideMainWindow( QSystemTrayIcon::ActivationReason ); void showConnectionWidget( bool ); void showGroupsDialog(); + void showHistoryDialog(); void setColorInducatorUsers( QString regExp ); void setColorInducatorBattles( QString regExp ); void startSpring(); void startSpringSettings(); void showStylesheetEditor(); - void setCurrentUsername( QString username ); void onCurrentChanged(const QModelIndex & current, const QModelIndex & previous); void onCurrentTabChanged(); void onTeamPlayerSpecCountChanged(QString ratio); diff --git a/src/MapInfoLoader.cpp b/src/MapInfoLoader.cpp index 9b2ef60..bb1a74e 100644 --- a/src/MapInfoLoader.cpp +++ b/src/MapInfoLoader.cpp @@ -187,9 +187,9 @@ void MapInfoLoader::saveCache() { } bool MapInfoLoader::loadCache() { - QDir userDir(Settings::Instance()->value("spring_user_dir").toString()); - if (!userDir.exists("qtlobby")) return false; - userDir.cd("qtlobby"); + QDir userDir(PathManager::getInstance()->resolveOverlayPath()); + if(!userDir.exists("cache")) return false; + userDir.cd("cache"); QFile file(QString("%1/%2.qmc") .arg(userDir.absolutePath()) .arg(m_mapName)); diff --git a/src/PathManager.cpp b/src/PathManager.cpp index 8814b91..8ca33f1 100644 --- a/src/PathManager.cpp +++ b/src/PathManager.cpp @@ -5,6 +5,8 @@ #include PathManager::PathManager() { + m_overlay = QString::null; + m_overlayUsable = false; } void PathManager::setResourceRoot(const QString& path) { @@ -12,16 +14,22 @@ void PathManager::setResourceRoot(const QString& path) { } void PathManager::setOverlayPath(const QString& path) { - m_overlay = path + QDir::separator(); + QDir d(path); + if(d.exists()) { + m_overlay = path + QDir::separator(); + m_overlayUsable = true; + } else + m_overlayUsable = false; } QString PathManager::resolvePath(const QString& path) { - if(!m_inOverlay.contains(path)) - m_inOverlay[path] = QFile::exists(m_overlay+path); - if(m_inOverlay[path]) - return m_overlay + path; - else - return m_base + path; + if(m_overlayUsable) { + if(!m_inOverlay.contains(path)) + m_inOverlay[path] = QFile::exists(m_overlay+path); + if(m_inOverlay[path]) + return m_overlay + path; + } + return m_base + path; } QString PathManager::resolveOverlayPath(const QString& path) { @@ -32,6 +40,10 @@ QString PathManager::resolveOverlayPath() { return m_overlay; } +bool PathManager::isOverlayValid() { + return m_overlayUsable; +} + void PathManager::invalidateCache(const QString& path) { m_inOverlay[path] = QFile::exists(m_overlay+path); } diff --git a/src/PathManager.h b/src/PathManager.h index 7af104c..fd0b2f2 100644 --- a/src/PathManager.h +++ b/src/PathManager.h @@ -13,10 +13,12 @@ class PathManager : public Singleton { QString resolvePath(const QString& path); QString resolveOverlayPath(const QString& path); QString resolveOverlayPath(); + bool isOverlayValid(); void invalidateCache(const QString& path); private: QString m_base; QString m_overlay; + bool m_overlayUsable; QMap m_inOverlay; PathManager(); }; diff --git a/src/PrivateChannel.cpp b/src/PrivateChannel.cpp index f55b383..1f608bf 100644 --- a/src/PrivateChannel.cpp +++ b/src/PrivateChannel.cpp @@ -22,7 +22,7 @@ void PrivateChannel::receiveCommand( Command command ) { .arg( "<%1> %2" ) .arg( objectName() ) .arg( processInput(command.attributes.join( " " )))); - if(isActive == false && Settings::Instance()->value("Chat/notifyNewPrivateMessages").toBool()) + if(isActive == false && Settings::Instance()->value("Chat/notifyNewPrivateMessages").toBool() && !historyMode) { QString title = QString("PM from " + objectName()); QString message = QString(processInput(command.attributes.join( " " ))); @@ -34,7 +34,7 @@ void PrivateChannel::receiveCommand( Command command ) { if ( command.attributes.takeFirst() == objectName() && command.attributes.join( " " ).trimmed() != "" ) { insertLine( line.arg( "%1<%2> %3" ) .arg( flag( myUserName ) ) - .arg( myUserName ) + .arg( historyMode ? "me" : myUserName ) .arg( processInput(command.attributes.join( " " )))); } } else if ( command.name == "CLIENTMSG" ) { diff --git a/src/ServerContextState.cpp b/src/ServerContextState.cpp index 6422e74..267ce07 100644 --- a/src/ServerContextState.cpp +++ b/src/ServerContextState.cpp @@ -3,6 +3,7 @@ #include "ServerContextState.h" #include "Settings.h" +#include "ServerProfilesModel.h" #include "config.h" ServerContextState::ServerContextState( QObject * parent ) : NetworkInterface( parent ) { @@ -152,11 +153,8 @@ void ServerContextState::ping() { QTimer::singleShot( 20000, this, SLOT( ping() ) ); } -void ServerContextState::setConfiguration( QUrl url ) { - this->url = url; -} - void ServerContextState::establishConnection() { + QUrl url = ServerProfilesModel::getInstance()->getActiveProfile(); emit logWrite( QString( ">< %2 -> %3::%4" ) .arg( "address::port" ) .arg( url.host() ) @@ -165,6 +163,7 @@ void ServerContextState::establishConnection() { } void ServerContextState::authenticate() { + QUrl url = ServerProfilesModel::getInstance()->getActiveProfile(); emit connectionStateChanged( AUTHENTICATING ); QString user = url.userName(); @@ -279,10 +278,6 @@ void ServerContextState::receiveCommand( Command command ) { } } -QUrl ServerContextState::getConfiguration( ) { - return url; -} - void ServerContextState::acceptAgreement() { sendMessage( "CONFIRMAGREEMENT" ); emit logWrite( tr( ">> agreement accepted, trying to login now." ) ); diff --git a/src/ServerContextState.h b/src/ServerContextState.h index 761c19c..b32339a 100644 --- a/src/ServerContextState.h +++ b/src/ServerContextState.h @@ -53,7 +53,6 @@ class ServerContextState : public NetworkInterface { void registerNewAccount( QString user, QString password ); QString encodePassword( QString password ); private: - QUrl url; // server:port username:password for the TASServer is saved here bool keepaliveping; AgreementWidget* agreementWidget; QString agreement; @@ -79,8 +78,6 @@ public slots: void displayError( QAbstractSocket::SocketError ); void establishConnection(); void forceDisconnect(); - void setConfiguration( QUrl ); - QUrl getConfiguration( ); void connectionStateChanged( ServerContextState::State state ); void acceptAgreement(); diff --git a/src/ServerProfilesModel.cpp b/src/ServerProfilesModel.cpp index 682bbe5..607e445 100644 --- a/src/ServerProfilesModel.cpp +++ b/src/ServerProfilesModel.cpp @@ -123,3 +123,15 @@ QUrl ServerProfilesModel::parseUrl(const QString& str) { } return QUrl(); } + +void ServerProfilesModel::setActiveProfile(const QModelIndex& profile) { + m_active = m_profiles[profile.row()]; +} + +void ServerProfilesModel::setActiveProfile(const QUrl& url) { + m_active = url; +} + +QUrl ServerProfilesModel::getActiveProfile() { + return m_active; +} diff --git a/src/ServerProfilesModel.h b/src/ServerProfilesModel.h index f5a0b69..55881a1 100644 --- a/src/ServerProfilesModel.h +++ b/src/ServerProfilesModel.h @@ -24,6 +24,7 @@ class ServerProfilesModel : public QAbstractTableModel, public Singleton m_profiles; QSettings* m_settings; int m_autologin; + QUrl m_active; }; #endif // SERVERPROFILESMODEL_H diff --git a/src/Users.cpp b/src/Users.cpp index 618fb1a..043bd57 100644 --- a/src/Users.cpp +++ b/src/Users.cpp @@ -3,6 +3,7 @@ #include "Users.h" #include "UserGroup.h" #include "UserMenuBuilder.h" +#include "ServerProfilesModel.h" #include #include @@ -54,6 +55,7 @@ QStringList Users::getUsernamesList() { void Users::receiveCommand( Command command ) { // qDebug() << "command: " << command.toQString(); + QUrl url = ServerProfilesModel::getInstance()->getActiveProfile(); command.name = command.name.toUpper(); if ( command.name == "CLIENTSTATUS" ) { User u = infoChannelUserManager->getUser( command.attributes[0] ); @@ -159,10 +161,6 @@ void Users::receiveCommand( Command command ) { } } -void Users::setConfiguration( QUrl url ) { - this->url = url; -} - void Users::currentTabChanged( QString name, QString lobbyTabType ) { QString oldTabType = currentTabType; currentTabType = lobbyTabType; @@ -249,39 +247,39 @@ void Users::onMyStateChanged( User u ) { } void Users::onSideComboBoxChanged( int index ) { - User u = infoChannelUserManager->getUser( url.userName() ); + User u = infoChannelUserManager->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ); u.battleState.setSide(index); onMyBattleStateChanged( u ); } void Users::onSpecStateChanged( int state ) { bool isSpec = state == Qt::Checked; - User u = infoChannelUserManager->getUser( url.userName() ); + User u = infoChannelUserManager->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ); u.battleState.setPlayer(!isSpec); onMyBattleStateChanged( u ); } void Users::onReadyStateChanged( int state ) { bool isReady = state == Qt::Checked; - User u = infoChannelUserManager->getUser( url.userName() ); + User u = infoChannelUserManager->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ); u.battleState.setReady(isReady); onMyBattleStateChanged( u ); } void Users::onColorChanged(QColor c) { - User u = infoChannelUserManager->getUser( url.userName() ); + User u = infoChannelUserManager->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ); u.m_color = c; onMyBattleStateChanged(u); } void Users::onTeamNumberChanged( int i ) { - User u = infoChannelUserManager->getUser( url.userName() ); + User u = infoChannelUserManager->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ); u.battleState.setTeamNo(i-1); onMyBattleStateChanged(u); } void Users::onAllyTeamNumberChanged( int i ) { - User u = infoChannelUserManager->getUser( url.userName() ); + User u = infoChannelUserManager->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ); u.battleState.setAllyTeamNo(i-1); onMyBattleStateChanged(u); } @@ -361,12 +359,8 @@ void Users::wipeModels() { infoChannelUserManager->model()->clear(); } -QString Users::getCurrentUsername() { - return url.userName(); -} - void Users::onSpringStopped() { - User u = infoChannelUserManager->getUser( url.userName() ); + User u = infoChannelUserManager->getUser( ServerProfilesModel::getInstance()->getActiveProfile().userName() ); u.userState.setIngame(false); onMyStateChanged( u ); } diff --git a/src/Users.h b/src/Users.h index 31e2d57..9986869 100644 --- a/src/Users.h +++ b/src/Users.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -31,7 +30,6 @@ class Users : public UsersTreeView { UserTreeModel* getUserModel(int battleId); int usersCountInCurrentChannel(); void wipeModels(); - QString getCurrentUsername(); void modUserInAllManagers( User ); QString teamPlayerSpecCount(); int usersInChanCount(); @@ -46,7 +44,6 @@ class Users : public UsersTreeView { public slots: void setRegExp( QString regExp ); void receiveCommand( Command command ); - void setConfiguration( QUrl url ); void currentTabChanged( QString name, QString lobbyTabType ); void inv(); void onMyBattleStateChanged( User u ); @@ -90,7 +87,6 @@ protected slots: void updateUserList(); TreeSortFilterProxyModel* proxyModel; QRegExp clanRegexp; - QUrl url; int userCount; int moderatorCount; static Users* lastThis; diff --git a/ui/HistoryDialog.ui b/ui/HistoryDialog.ui new file mode 100644 index 0000000..93fb757 --- /dev/null +++ b/ui/HistoryDialog.ui @@ -0,0 +1,73 @@ + + + HistoryDialog + + + + 0 + 0 + 704 + 573 + + + + Channel history + + + + + + + + + Qt::Horizontal + + + + Type: + + + + + + Channel + + + + + Private + + + + + + Name: + + + + + + From: + + + + + + To: + + + + + + + + + + ChannelTextBrowser + QTextBrowser +
ChannelTextBrowser.h
+
+
+ + +
diff --git a/ui/MainWidget.ui b/ui/MainWidget.ui index 5ed249d..9e94896 100644 --- a/ui/MainWidget.ui +++ b/ui/MainWidget.ui @@ -78,6 +78,7 @@ + @@ -623,6 +624,11 @@ Ctrl+H + + + History + + @@ -834,6 +840,22 @@ + + actionHistory + triggered() + MainWindow + showHistoryDialog() + + + -1 + -1 + + + 397 + 367 + + + @@ -855,5 +877,6 @@ showStylesheetEditor() showGroupsDialog() + showHistoryDialog()